Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras / Tensorflow : "You must feed a value for placeholder tensor 'input_1' with dtype float and shape [?, 600, 451, 3]"

I have this CNN I'm working on. Input shape is dynamic, but I fixed it to [?, 600, 451, 3] (batch_size, height, width, channels) so that I can debug it.

I have a random batch generator I created:

test = random_batch_generator(z_train
                    , num_processes=12 
                    , num_batch=steps_train 
                    , preloaded_batch=100
                    , batch_size=batch_size
                    , chunk_size=batch_size
                    , dataaugmfunc=heavy_dataaugm
                    , seq=seq
                    , initial_dim=initial_dim
                    , min_overlap=MINOVERLAP
                    )

When I do:

next(test)[0].shape

or

next(test)[0].dtype

it outputs me the correct shape ([?, 600, 451, 3]) and dtype (float32), which is in theory required for my input. I also checked the content of the batches, it seems good.

Still, I got, when I train my model with the following:

model.fit_generator(
        random_batch_generator(z_train (...)),
        validation_data= (x_val_mem,y_val_mem),
        steps_per_epoch=steps_train,
        validation_steps=steps_val,
        epochs=epochs
        ,callbacks=model_callbacks(modelname)
        ,class_weight = [0.005,0.995]
    )

this error message:

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input_1' with dtype float and shape [?,600,451,3]

[[Node: input_1 = Placeholderdtype=DT_FLOAT, shape=[?,600,451,3], _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

What am I doing wrong? Thanks a thousand for any help or intuition on this.

like image 612
Achille Avatar asked Jan 28 '23 17:01

Achille


1 Answers

Are you using a TensorBoard callback? If so, you could try adding this before creating the model

import keras.backend as K
K.clear_session()

See this answer

like image 88
pdpino Avatar answered Jan 31 '23 20:01

pdpino