5

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.

2
  • try initializing your generator class first, and then pass it to your model Commented Sep 6, 2019 at 10:57
  • also try to feed next(test)[0] to your model Commented Sep 6, 2019 at 11:16

4 Answers 4

6

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

0
2
  • most of the time this problem occures because of unused inputes(on your fit generator) are added to your network. try to avoid or put a comment on unused inputes in your network and try it again.if number of inputs for the model and number of inputs to batch generator or fit() function are not balanced this problem will happen.

before all you have to reset your session *

import keras.backend as K
K.clear_session()
1

Not sure this is the cause, but something is not compatible with the validation data.

If you have the validation data as arrays, you pass it as validation_data=(array_x, array_y), and there aren't validation_steps.

Now, if it's a generator, then you need to pass it as validation_data = someGenerator, then you pass validation_steps=number_of_batches_expected_from_generator.

4
  • Thanks for answering. Probably not the problem though, I trained the model before in the same fashion and it worked flawlessly. The problem seems more related to the training data / model shape rather than the validation "architecture".
    – Achille
    Commented Jul 23, 2018 at 20:50
  • No, the error is: you're not feeding data. There is feeding both in training and in validatoin. Since your training seems ok, I believe the validation might be the problem. Commented Jul 23, 2018 at 20:54
  • There might be more elaborated causes, though, like using masking, TimeDistributed layers, custom functions, etc. Nothing really clear or understandable. Commented Jul 23, 2018 at 20:55
  • My validation set has shape (num_batch, 600, 451, 3) and dtype float32, I checked as well... I'm using custom layers (the model compiles right), and there is only 1 input in the model.
    – Achille
    Commented Jul 24, 2018 at 7:44
0

This happened to me (TF 1.14) when I set 'histogram_freq = 1' instead of 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.