1. Object of type 'float32' is not JSON serializable,这个问题是因为tensorflow计算过程中得到的float类型是<class 'numpy.float32'>,是不被json支持的,直接用float()转换就好;
2. 类似
File "/home/lin/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 5649, in _assert_same_graph\n original_item))\n'] <class 'ValueError'> Tensor("Variable:0", shape=(1, 50), dtype=float32_ref) must be from the same graph as Tensor("1/Reshape:0", shape=(?, 1), dtype=float32).
这样的错误,重点在于must be from the same graph,我是分了三个文件,一个是训练并保存模型,一个导入模型,一个是dao文件,lstm神经网络的定义放在dao文件,其他两个从dao文件import进去,就出现了这样的错误,解决方法是,在dao文件中定义网络结构时,使用
lstm_graph = tf.Graph()
with lstm_graph.as_default():
weights = {
'in': tf.Variable(tf.random_normal([input_size, lst