How to Convert a Linear Model to Conv1 in Pytorch?
I am new to Pytroch and I cannot transform Keras models that I have in my mind in to it.
I have a really simple linear model in Pytorch as follows:
class linear_model(nn.Module):
    def __init__(self, output, activation=nn.ReLU):
        super(linear_model, self).__init__()
        self.net = nn.Sequential(
            nn.Linear(26, 26),
            activation(),
            nn.Linear(26, 26),
            activation(),
            nn.Linear(26, 26),
            activation(),
            nn.Linear(26, 26),
            activation(),
            nn.Linear(26, 26),
            activation(),
            nn.Linear(26, 26),
            activation(),
            nn.Linear(26, 6)
        )

    def forward(self, x):
        out = self.net(x)
        return out

I want to use Conv1d instead of a linear layer. Something like this:
class resnet(nn.Module):
    def __init__(self, output, activation=nn.ReLU):
        super(resnet, self).__init__()
        self.net = nn.Sequential(
            nn.Linear(26, 64),
            activation(),           
            nn.Conv1d(64, 64, kernel_size=5,padding=2),
            activation(), 
            nn.MaxPool1d(3,stride=1, padding=1),
            nn.Conv1d(64, 32, 3,padding=1,stride=2),
            activation(), 
            nn.MaxPool1d(3,stride=1, padding=1),
            nn.Linear(32, 6)
        )

    def forward(self, x):
        out = self.net(x)
        return out

The first Conv1d needs an [64,64,6] input and I provide it an [10,64] input (the batch size is 10).
To summarize, I have an array [1,26] and I want to feed into the network, increase its size to [1,64], then reduce it to [1,6] at the end.
I'm conflicting with the concepts of Keras and Pytorch. How should I correct the problem?
Edit:
I have changed the model, and now it's working. After all, I have no clue what's going on there. Here is the new one:
class custom_model(nn.Module):
def __init__(self, output, activation=nn.ReLU):
    super(custom_model, self).__init__()
    self.net = nn.Sequential(
        nn.Linear(num_features, 64),
        nn.Dropout(p=0.5),
        nn.ReLU(),           
        nn.Conv1d(1, 64, kernel_size=5,padding=2),
        activation(), 
        nn.MaxPool1d(3,stride=1, padding=1),
        nn.Conv1d(64, 32, 3,padding=1,stride=2),
        activation(), 
        nn.MaxPool1d(3,stride=1, padding=1),
        nn.Conv1d(32, 6, 1),
        activation(),
        #nn.Conv1d(6, 6, 1)
        nn.Linear(32, output),
        nn.Dropout(p=0.5),
        nn.ReLU(),
        nn.Linear(6, 1),


    )

def forward(self, x):
    x = torch.unsqueeze(x,1)
    out = self.net(x)

    return out

And, changed the way I calculate the loss to make it compatible:
outputs = model(inputs)
outputs_squeezed = torch.squeeze(outputs)
loss_value = loss(outputs_squeezed, y_train)

The model I devised is not necessary correct (I mean, the concept behind it). I just cannot figure out what is happening. To make it clear, I cannot understand what are the input and output of the Conv1d and how I can connect them correctly.

The data you are passing is that of single-point data. The difference between data of shape [B,N,L] for 1D tensors and [B,N] for single-point tensors is critical for the application of N-D convolutions (in this case B is batch size, L is sequence length, and N is feature depth).
To solve this for your case, just add a dimension to your data so that N=1, because at the moment you do not have a third dimension. However, according to your question I am unsure if you're missing the batch (first) dimension or the feature (second) because you say you provide both, but not simultaneously? Nevertheless, I think this can be entirely amended by:
input = input[:,None,:]

Or
input = torch.unsqueeze(input,1)

