Multidimensional-time-series-with-transformer
                                
                                 Multidimensional-time-series-with-transformer copied to clipboard
                                
                                    Multidimensional-time-series-with-transformer copied to clipboard
                            
                            
                            
                        模型读取报错
RuntimeError: The expanded size of the tensor (3) must match the existing size (4) at non-singleton dimension 1. Target sizes: [5000, 3]. Tensor sizes: [5000, 4]
不知道问题出在哪里,数据格式跟您的也是一样的,只不过是7维特征,单步输出
RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_20169/760475506.py in 
/tmp/ipykernel_20169/444366459.py in init(self, feature_size, num_layers, dropout) 5 6 self.src_mask = None ----> 7 self.pos_encoder = PositionalEncoding(feature_size) 8 self.encoder_layer = nn.TransformerEncoderLayer(d_model=feature_size, nhead=7, dropout=dropout) 9 self.transformer_encoder = nn.TransformerEncoder(self.encoder_layer, num_layers=num_layers)
/tmp/ipykernel_20169/3101524472.py in init(self, d_model, max_len) 7 div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model)) 8 pe[:, 0::2] = torch.sin(position * div_term) ----> 9 pe[:, 1::2] = torch.cos(position * div_term) 10 pe = pe.unsqueeze(0).transpose(0, 1) 11 #pe.requires_grad = False
RuntimeError: The expanded size of the tensor (3) must match the existing size (4) at non-singleton dimension 1. Target sizes: [5000, 3]. Tensor sizes: [5000, 4]
想问一下特征不能是单数吗
想问一下特征不能是单数吗
不能
应该是网络结构和输入特征不匹配,建议修改神经网络输入维度大小。如果还有问题,欢迎继续讨论。