下記の通り、mode.evaluateでエラーが出ており次に進めない状況となっています。
このエラーでの対策をご教授願いたいと思います。
python3
1text = np.loadtxt('outPut.csv', delimiter=',') 2 FEATURE = text[:, :2] 3 LABEL = text[:, 2] 4 5 6 FEATURE = FEATURE / 64.0 7 8 model = tf.keras.Sequential([ 9 tf.keras.layers.Dense(2, activation='relu'), 10 tf.keras.layers.Dense(9, activation='softmax') 11 ]) 12 13 model.compile(optimizer='adam', 14 loss='sparse_categorical_crossentropy', 15 matrics=['accuracy']) 16 17 model.fit(FEATURE, LABEL, epochs=100) 18 19 test_loss, test_acc = model.evaluate(FEATURE, LABEL) 20 21 print('\nTest accuracy:', test_acc)
log
1Traceback (most recent call last): 2 File "<input>", line 1, in <module> 3 File "/Applications/Jetbrains/apps/PyCharm-P/ch-0/192.6603.34/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile 4 pydev_imports.execfile(filename, global_vars, local_vars) # execute the script 5 File "/Applications/Jetbrains/apps/PyCharm-P/ch-0/192.6603.34/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile 6 exec(compile(contents+"\n", file, 'exec'), glob, loc) 7 File "/Users/azuma.t/git/tensorflow-hevc/20190917.py", line 70, in <module> 8 test_loss, test_acc = model.evaluate(FEATURE, LABEL) 9TypeError: cannot unpack non-iterable numpy.float64 objec
data
164.0,64.0,5 264.0,64.0,2 332.0,64.0,1 432.0,64.0,5 532.0,64.0,8 632.0,64.0,5 764.0,32.0,3 864.0,32.0,3 964.0,32.0,2 1064.0,32.0,7 1132.0,32.0,4 1232.0,32.0,8 1316.0,32.0,0 1416.0,32.0,2 1516.0,32.0,8 1616.0,32.0,1 1732.0,16.0,8 1832.0,16.0,1 1932.0,16.0,4 2032.0,16.0,5 2132.0,24.0,0...
一番最初の Dense に input_dim 引数で入力の次元数 (例: input_dim=2) を指定したらどうなりますか?
あなたの回答
tips
プレビュー