突然テンソルフローバックエンド(python2.7)のkearsですべてのコードで同じエラーが発生します。私は、そのkeras 1及び2の非互換性を考えたが、それは「私が同様の問題(リンク↓↓)のようtensorflowとkeras両方を更新 ValueError:KerasのDimension(-1)は範囲[0,2]にある必要があります
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: [?,?], [].
なかったが、それでも同じエラー
ValueError: Dimension (-1) must be in the range [0, 2) フルコード(例)
**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: [?,?], [].'
歓迎され、あなたは「categorical_crossentropy」または「ソフトマックス」や「RMSprop」を使用していますか? 'y_train'(ラベル/真の値/ターゲット)の形は何ですか? –
ありがとう、私はこのMLPの例を使用して私の問題をより明確にしていますhttps://github.com/fchollet/keras/blob/master/examples/mnist_mlp.py –
最後の層は何ですか?それは "正確に"そのコードですか? –