Python 神经网络的三维绘图

Python 神经网络的三维绘图,python,numpy,tensorflow,matplotlib,Python,Numpy,Tensorflow,Matplotlib,我试图通过绘制3D曲面图来可视化最佳区域,其中X表示层数,Y表示历元数,Z表示平均误差百分比 import matplotlib.pyplot as plt import numpy as np ## Defining X, Y, Z for the 3d plot # X represents the number of layers X = [3,4,5,6,7,8,9,10,11,12] # Y represents the number of epochs Y = [10,20,

我试图通过绘制3D曲面图来可视化最佳区域,其中X表示层数,Y表示历元数,Z表示平均误差百分比

import matplotlib.pyplot as plt
import numpy as np
## Defining X, Y, Z for the 3d plot
# X represents the number of layers

X = [3,4,5,6,7,8,9,10,11,12]

# Y represents the number of epochs 

Y = [10,20,30,50,100,200,300,400,500,600]

# Z represents Mean Percent Error
# itertools will be used to show how Z will look like 
import itertools
Z = ['10','9','8','7','6','5','4','3','2','1']
# Possible combinations of 10 numbers
Z_1 = list(itertools.combinations_with_replacement(Z,10))
print(Z_1)

因此,对于每个#层,有对应的10个不同的#时代,有10个对应的Z,这意味着Z将是一个字符串列表,每个列表中有10个元素

在那之后,我试过了

# Reshaping the data

x = np.reshape(X, (10))
y = np.reshape(Y, (10))
z = np.reshape(Z, (660, 1))


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.plot_surface(x,y,z)
ax.set_xlabel('Number of Layers')
ax.set_ylabel('Number of Epochs')
ax.set_zlabel('% Error')

ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
从哪里开始有什么帮助吗?要修复什么


非常感谢你的帮助。谢谢大家!

变量是什么?@Anwarvic我编辑了变量O,它是一个打字错误,而不是Z。在问题中,你说
Z
是一个列表。。。但我能看到的只是一个字符串列表。此外,
Z
无法重新塑造为此形状。我已编辑为字符串。我应该如何开始解决这个问题?我想可视化最佳区域,即低百分比错误区域。变量
O
是什么?@Anwarvic我编辑了变量O,它是一个拼写错误,而不是Z。在问题中,你说
Z
是一个列表。。。但我能看到的只是一个字符串列表。此外,
Z
无法重新塑造为此形状。我已编辑为字符串。我应该如何开始解决这个问题?我想可视化最佳区域,即低百分比误差区域。