问题描述
使用 Google 的 colab 我已经训练了一个 keras 模型。
Model: "sequential_1"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_4 (Dense) (None,256) 131328
_________________________________________________________________
dense_5 (Dense) (None,128) 32896
_________________________________________________________________
dense_6 (Dense) (None,64) 8256
_________________________________________________________________
dense_7 (Dense) (None,22) 1430
=================================================================
Total params: 173,910
Trainable params: 173,910
Non-trainable params: 0
_________________________________________________________________
None
但是,当我为我的测试数据尝试 model.predict() 时。这给了我以下错误。
InvalidArgumentError Traceback (most recent call last)
<ipython-input-13-2dd0bff687f9> in <module>()
1 X_test_tensor = tf.convert_to_tensor(X_test)
----> 2 test_predict = model.predict(X_test)
6 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name,num_outputs,inputs,attrs,ctx,name)
58 ctx.ensure_initialized()
59 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle,device_name,op_name,---> 60 inputs,num_outputs)
61 except core._NotOkStatusException as e:
62 if name is not None:
InvalidArgumentError: cannot compute __inference_pruned_16232 as input #0(zero-based) was expected to be a string tensor but is a float tensor [Op:__inference_pruned_16232]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)