训练模型时索引

发布于 2025-02-01 05:25:32 字数 844 浏览 1 评论 0原文

在训练手语翻译的同时,从Github培训了预先开发的代码进行演示。在训练模型时,收到了错误。 这里,

num_of_classes = 7 input_size =(50,50) 火车图像形状:(3670,50,50,1)和 验证图像形状:(367,50,50,1)

火车标签形状:(3670,1008)和验证标签形状:(367,1008)

valueerror:形状(无,1008)和(无,7)不兼容

标签的形状由于输入标签的形状不匹配。

train_images = np.reshape(train_images, (train_images.shape[0],
image_x, image_y, 1))
val_images = np.reshape(val_images,(val_images.shape[0], image_x, image_y, 1)) 
train_labels = utils.to_categorical(train_labels)#,num_classes = 7) 
val_labels = utils.to_categorical(val_labels)#,num_classes = 7)

utils.to_categorical(val_labels,num_classes =7)

发现训练标签和验证

indexError:索引1003的范围不超出 尺寸7。

的轴1

如何解决此问题?

While training a sign language translation pre-developed code from GitHub for demonstration. While training a model, received a error.
Here,

num_of_classes = 7
Input_size=(50,50)
The train image shape: (3670, 50, 50, 1) and
Validation image shape : (367, 50, 50, 1)

The train labels shape: (3670, 1008) and Validation labels shape : (367, 1008)

ValueError: shape(None, 1008) and (None,7) are incompatible

I found that training label and validation label shape is mismatching because of input labels shape:

train_images = np.reshape(train_images, (train_images.shape[0],
image_x, image_y, 1))
val_images = np.reshape(val_images,(val_images.shape[0], image_x, image_y, 1)) 
train_labels = utils.to_categorical(train_labels)#,num_classes = 7) 
val_labels = utils.to_categorical(val_labels)#,num_classes = 7)

So, changed to

utils.to_categorical(val_labels,num_classes =7)

But, getting another,

IndexError: index 1003 is out of bounds for
axis 1 with size 7.

How to solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文