Plötzlich habe ich diesen Fehler mit Kears mit Tensorflow Backend (Python2.7), der gleiche Fehler mit jedem Code. Ich dachte, seine keras 1 und 2 Unverträglichkeit, aber es war nichtValueError: Dimension (-1) muss im Bereich [0, 2) in Keras sein
Dimension (-1) must be in the range [0, 2), where 2 is the number of dimensions in the input. for 'metrics/acc/ArgMax' (op: 'ArgMax') with input shapes: [?,?], [].
‚aktualisiere ich sowohl tensorflow und keras wie ähnliches Problem (Link ↓↓), aber immer noch denselben Fehler ValueError: Dimension (-1) must be in the range [0, 2) Der vollständige Code (Beispiel)
**Code updated the whole code**
using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
60000 train samples
10000 test samples
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, 512) 401920
_________________________________________________________________
dropout_1 (Dropout) (None, 512) 0
_________________________________________________________________
dense_2 (Dense) (None, 512) 262656
_________________________________________________________________
dropout_2 (Dropout) (None, 512) 0
_________________________________________________________________
dense_3 (Dense) (None, 10) 5130
=================================================================
Total params: 669,706
Trainable params: 669,706
Non-trainable params: 0
_________________________________________________________________
Traceback (most recent call last):
File "mnist_mlp.py", line 48, in <module>
metrics=['accuracy'])
File "/home/usr/miniconda2/lib/python2.7/site-packages/keras/models.py", line 784, in compile
**kwargs)
File "/home/usr/miniconda2/lib/python2.7/site-packages/keras/engine/training.py", line 924, in compile
handle_metrics(output_metrics)
File "/home/usr/miniconda2/lib/python2.7/site-packages/keras/engine/training.py", line 921, in handle_metrics
mask=masks[i])
File "/home/usr/miniconda2/lib/python2.7/site-packages/keras/engine/training.py", line 450, in weighted
score_array = fn(y_true, y_pred)
File "/home/usr/miniconda2/lib/python2.7/site-packages/keras/metrics.py", line 25, in categorical_accuracy
return K.cast(K.equal(K.argmax(y_true, axis=-1),
File "/home/usr/miniconda2/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1333, in argmax
return tf.argmax(x, axis)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 249, in argmax
return gen_math_ops.arg_max(input, axis, name)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 168, in arg_max
name=name)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2242, in create_op
set_shapes_for_outputs(ret)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1617, in set_shapes_for_outputs
shapes = shape_func(op)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1568, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn)
File "/home/usr/.local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 675, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimension (-1) must be in the range [0, 2), where 2 is the number of dimensions in the input. for 'metrics/acc/ArgMax' (op: 'ArgMax') with input shapes: [?,?], [].'
Sie ein ‚categorical_crossentropy‘ mit oder einer ‚softmax‘ oder einem ‚RMSprop‘? Wie ist die Form deines y_train (Etiketten/wahre Werte/Ziele)? –
Danke, ich benutze dieses MLP-Beispiel, um mein Problem klarer zu machen https://github.com/fchollet/keras/blob/master/examples/mnist_mlp.py –
Was ist deine letzte Schicht? Ist es "genau" dieser Code? –