AttributeError: 'Sequential' object has no attribute 'size'
I'm new in pytorch and just try to write a network. The data.shape is (204,6170) and the last 5 cols are some labels. The number in data is float number like 0.030822.
#%%
from sklearn.feature_selection import RFE
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from sklearn.model_selection import train_test_split
import torch.functional as F

#%%
data = pd.read_table(&quot;table.log&quot;)
data_x = data.iloc[:, 0:(data.shape[1]-5)]
data_y = data.loc[:, 'target']
X_train, X_test, y_train, y_test = train_test_split(data_x,data_y,test_size=0.2,random_state=0)

#%%
from sklearn.linear_model import LinearRegression
lr = LinearRegression(normalize=True)
lr.fit(X_train,y_train)
rfe1 = RFE(estimator=lr,n_features_to_select=2000)
rfe1 = rfe1.fit(X_train,y_train)

#%%
x_train_rfe1 = X_train[X_train.columns[rfe1.support_]]
print(x_train_rfe1.head())
class testmodel(nn.Module):
    def __init__(self):
        super(testmodel,self).__init__()
        self.conv = nn.Sequential(
            nn.Conv1d(1500, 500, 1500, 0, 0),
            nn.ReLU(),
            nn.Conv1d(500, 100, 500, 0),
            nn.ReLU(),
            nn.Conv1d(100, 20, 100, 0),
            nn.Sigmoid()
        )
    def forward(self,x):
        x = self.conv
        return x
#%%
x_train_rfe1 = torch.Tensor(x_train_rfe1.values)
y_train = torch.Tensor(y_train.values.astype(np.int64))
model = testmodel()
y = model(x_train_rfe1)

criterion = nn.MSELoss()
loss = criterion(y, y_train)
print(loss)

error message:
Traceback (most recent call last):
  File &quot;&lt;input&gt;&quot;, line 7, in &lt;module&gt;
  File &quot;/miniconda3/envs/ml/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 532, in __call__
    result = self.forward(*input, **kwargs)
  File &quot;/miniconda3/envs/ml/lib/python3.8/site-packages/torch/nn/modules/loss.py&quot;, line 431, in forward
    return F.mse_loss(input, target, reduction=self.reduction)
  File &quot;/miniconda3/envs/ml/lib/python3.8/site-packages/torch/nn/functional.py&quot;, line 2203, in mse_loss
    if not (target.size() == input.size()):
  File &quot;/miniconda3/envs/ml/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 575, in __getattr__
    raise AttributeError(&quot;'{}' object has no attribute '{}'&quot;.format(
AttributeError: 'Sequential' object has no attribute 'size'

Where can the error was?
Is the internet usually written like this?
How could I improve it?

You never run your input tensor x through your conv sequential layer in forward.
def forward(self, x):
    x = self.conv(x)
    return x

Do some PyTorch tutorials they will help you get the basics down: https://pytorch.org/tutorials/
