获取“numpy.int64”对象不可调用并且“张量之间的大小不匹配”构建 MLP 时 PyTorch 中的错误

发布于 2025-01-19 02:38:27 字数 616 浏览 1 评论 0原文

我有 4 个文本文件,其中一个包含 x1x2x3 作为训练特征,另一个是 y 作为标签,相同适用于测试。
我必须在 Pytorch 中构建多层感知器(MLP)模型 我所做的是将这些文本文件加载到 PyTorch,名称为 x_trainy_trainx_testy_test.
但是,当我运行下面的代码时:

dataset_train = data.TensorDataset(x_train,y_train)
dataloader_train =data.DataLoader(dataset_train, batch_size=10, shuffle=True,num_workers=0)

我收到此错误:

'numpy.int64' object is not callable

我还看到:张量之间的大小不匹配
请帮我解决这个错误,它是什么意思以及我必须更改什么?

I have 4 text files,one of which includes x1,x2,x3 as training features and the other one is y for labels and the same applies to testing.
I have to construct a Multi Layer Perceptron (MLP) model in Pytorch
and what I did was to load these text files to PyTorch under the names of x_train,y_train,x_test and y_test.
However when I run the code below:

dataset_train = data.TensorDataset(x_train,y_train)
dataloader_train =data.DataLoader(dataset_train, batch_size=10, shuffle=True,num_workers=0)

I get this error :

'numpy.int64' object is not callable

I also see this : Size mismatch between tensors.
please help me with this error,what does it mean and what I have to change ?

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

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

发布评论

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