import matplotlib.pyplot as plt
x_arr = np.arange(-2, 4, 0.1)
g2 = tf.Graph()
with tf.Session(graph = g2) as sess:
new_saver = tf.train.import_meta_graph(
"./trained-model.meta")
new_saver.restore(sess, "./trained-model")
y_arr = sess.run("y_hat:0",
feed_dict = {"tf_x:0", x_arr})
plt.figure()
plt.plot(x_train, y_train, "bo")
plt.plot(x_test, y_test, "bo", alpha = 0.3)
plt.plot(x_arr, y_arr.T[:,0], "-r", lw = 3)
plt.show()
输出
TypeError跟踪(最近一次通话最近) 在 12 13 y_arr = sess.run(“ y_hat:0”, ---> 14 feed_dict = {“ tf_x:0”,x_arr}) 15 16 plt.figure()
TypeError:不可散列的类型:'numpy.ndarray'
答案 0 :(得分:0)
您需要将x_arr
转换为张量类型。您可以通过tf.convert_to_tensor(x_arr)
进行此操作。