首页 > 解决方案 > 神经网络的 3d 图

问题描述

我试图通过绘制 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 个不同的 # epochs,并且有 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''

从哪里开始有任何帮助吗?要解决什么?

您的帮助将不胜感激。谢谢!

标签: pythonnumpytensorflowmatplotlib

解决方案


推荐阅读