RuntimeError:大小不匹配,m1:[192 x 68],m2:[1024 x 68],位于/opt/conda/conda-bld/pytorch_/work/aten/src/THC/generic/THCTensorMathBlas.cu:268

时间:2019-08-02 07:24:46

标签: pytorch

我收到了一个我不明白的尺寸不匹配错误。

chart.data = [
  {"year": "2013",    "A": 100.5605895, "B": 200.2631216, },
  {"year": "2014",    "A": 100.9491154, "B": 200.7340505, },
  {"year": "2015",    "A": 100.9897489, "B": 200.6443121, },
  {"year": "2016",    "A": 100.4639869, "B": 200.3362392, },
  {"year": "2017",    "A": 100.9213508, "B": 200.9948514, },
];

// Create axes
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "year";

var  valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.title.text = "Value";

var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.valueY = "B";
series.dataFields.categoryX = "year";
series.name = "B";

var series2 = chart.series.push(new am4charts.LineSeries());
series2.dataFields.valueY = "A";
series2.dataFields.categoryX = "year";
series2.name = "A";

为什么不匹配? 也许是因为我在(Pdb) self.W_di Linear(in_features=68, out_features=1024, bias=True) (Pdb) indices.size() torch.Size([32, 6, 68]) (Pdb) self.W_di(indices) *** RuntimeError: size mismatch, m1: [192 x 68], m2: [1024 x 68] at /opt/conda/conda-bld/pytorch_1556653099582/work/aten/src/THC/generic/THCTensorMathBlas.cu:268 (而不是forward)中定义权重的方式?

这就是我定义_init_的方式:

self.W_di

任何指针将不胜感激!

2 个答案:

答案 0 :(得分:1)

通常可以在here中查看我的答案

self.W_di = nn.Linear(mL_n * 2, 68)

或增加in功能。

答案 1 :(得分:0)

通常我们在 cnn 中也会遇到这个错误,当您的输入图像没有调整到模型的预期大小时。