python - 神经网络的 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''
从哪里开始有任何帮助吗?要解决什么?
您的帮助将不胜感激。谢谢!
解决方案
推荐阅读
- directus - 有没有办法配置/控制哪些字段出现在 Directus 中的集合的批量编辑模式中?
- javascript - null 不是对象(评估“blob.data”)获取反应
- python - 如果字符大,如何插入数字?
- dask - 如何将 jupyter notebook 中的节点与 dask 链接
- r - 如何创建一个能够区分具有相同值的两个对象的条件?
- jenkins - Jenkinsfile - 仅在检测到更改时才触发定时(cron)
- arrays - 将文本文件中的行解析为存储在包含不同数据类型的类数组中的变量
- java - ObjectMapper 无法将值列表写入字符串
- python - 使用 OpenCv 在 Python 中对多个图像进行阈值处理
- r - 如何在 pROC 中为 multiclass.roc 绘图添加标题?