#Custom Loss function Cannot squeeze axis=-1

1 messages · Page 1 of 1 (latest)

sour kettle
#

For more context: each sample is composed by 6 components (3 for Accelerometer, 3 for Gyroscope) and I used that data do define some boundaries in which some new derived data (like mean, standard deviation...) resides. Using these boundaries, I wanted to penalize a prediction if the sample was too far away from the rules values, hopefully increasing accuracy. But I have been getting a lot of errors, and this one I cannot really understand.

If you have any additional tips on the custom loss, I would be happy to hear them since it's my first time working with a custom one.

Thanks in advance!

sonic raven
#

Please upload a .txt or .py file

#

I've deleted the .bin file

sour kettle
#
Making conv1d_lstm model with input shape (50, 6), hidden 64, 128, out classes 8
Epoch 1/10
y_pred.shape=TensorShape([None, 8]) y_train_labels_one_hot.shape=TensorShape([None, 8])

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

<ipython-input-323-127b82319b96> in <cell line: 11>()
      9 
     10 # Train the model
---> 11 model.fit(x_train, padded_data, epochs=10, batch_size=32, validation_split=0.2)

1 frames

/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py in error_handler(*args, **kwargs)
    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

/usr/local/lib/python3.10/dist-packages/keras/src/backend/tensorflow/numpy.py in squeeze(x, axis)
   2303         for a in axis:
   2304             if static_shape[a] != 1:
-> 2305                 raise ValueError(
   2306                     f"Cannot squeeze axis={a}, because the "
   2307                     "dimension is not 1."

ValueError: Cannot squeeze axis=-1, because the dimension is not 1.