[Python] Invalid input shape for input Tensor

Discussão em 'Python' iniciado por Stack, Novembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    Tomato project

    the model is building but it is refusing to train. it is saying incorrect format given for the input_shape and i have tried everything that i know possible. the model error is

    Epoch 1/50
    ---------------------------------------------------------------------------
    ValueError Traceback (most recent call last)
    Cell In[70], line 1
    ----> 1 history = model.fit(
    2 train_ds,
    3 epochs = EPOCHS,
    4 batch_size = BATCH_SIZE,
    5 verbose =1,
    6 validation_data = val_ds
    7 )

    File /opt/conda/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    119 filtered_tb = _process_traceback_frames(e.__traceback__)
    120 # To get the full stack trace, call:
    121 # `keras.config.disable_traceback_filtering()`
    --> 122 raise e.with_traceback(filtered_tb) from None
    123 finally:
    124 del filtered_tb

    File /opt/conda/lib/python3.10/site-packages/keras/src/models/functional.py:285, in Functional._adjust_input_rank(self, flat_inputs)
    283 adjusted.append(ops.expand_dims(x, axis=-1))
    284 continue
    --> 285 raise ValueError(
    286 f"Invalid input shape for input {x}. Expected shape "
    287 f"{ref_shape}, but input has incompatible shape {x.shape}"
    288 )
    289 # Add back metadata.
    290 for i in range(len(flat_inputs)):

    ValueError: Exception encountered when calling Sequential.call().

    Invalid input shape for input Tensor("data:0", shape=(None, 256, 256, 3), dtype=float32). Expected shape (256, 256), but input has incompatible shape (None, 256, 256, 3)

    Arguments received by Sequential.call():
    • inputs=tf.Tensor(shape=(None, 256, 256, 3), dtype=float32)
    • training=True
    • mask=None

    Continue reading...

Compartilhe esta Página