awslabs / keras-apache-mxnet

[DEPRECATED] Amazon Deep Learning's Keras with Apache MXNet support
https://github.com/awslabs/keras-apache-mxnet/wiki
Other
290 stars 65 forks source link

Confusing warning for loss function #139

Closed roywei closed 6 years ago

roywei commented 6 years ago

Running a simple example under examples/mnist_cnn.py will produce the following warning:

/Users/lawei/Documents/Workspace/roywei/keras/keras/losses.py:128: UserWarning: MXNet Backend: If you are using a custom loss function and use slice operator in custom loss function, please set the **_keras_shape** attribute of the loss tensor explicitly.

Without this workaround, you may encounter shape mismatch errors in the broadcast operations.

For more details - https://github.com/awslabs/keras-apache-mxnet/issues/120

  warnings.warn('MXNet Backend: If you are using a custom loss function and use slice operator in custom '

Although it does not use any custom loss nor slice.

model.compile(loss=keras.losses.categorical_crossentropy,
              optimizer=keras.optimizers.Adadelta(),
              metrics=['accuracy'])
roywei commented 6 years ago

@sandeep-krishnamurthy is this correct behavior? I didn't find this problem in other cnn examples

sandeep-krishnamurthy commented 6 years ago

No, this warning should be shown only if custom loss is used. Will look into it.

roywei commented 6 years ago

@sandeep-krishnamurthy update: tried to change: loss=keras.losses.categorical_crossentropy to loss='categorical_crossentropy' warning is gone.

roywei commented 6 years ago

Closing as fixed in #158