can i use the tf-idf matrix as input to the conventional auto-encoder composed of conv1d layers?
here is the form of my df-idf data
>>> tfidf.shape
>>>(3047,500)
I use a batch of size 64 , and i reshape the input by this line
x = x.reshape(x.shape[0], x.shape[1],1)
the input is become of this form
input[64, 500, 1]
my class are as follows
class Encoder(nn.Module):
def __init__(self, input_size, intermediate_size, encoding_size):
super().__init__()
self.encoder = nn.Sequential(
nn.Conv1d(500, 100, 1),
nn.BatchNorm1d(100),
nn.ReLU(True),
nn.MaxPool1d(kernel_size=1, stride=1),
nn.Dropout(0.2),
nn.Conv1d(100, 50, 1),
nn.BatchNorm1d(50),
nn.ReLU(True),
nn.MaxPool1d(kernel_size=1, stride=1),
nn.Dropout(0.2))
def forward(self, x):
x = x.reshape(x.shape[0], x.shape[1],1)
x = self.encoder(x)
return x
class Decoder(nn.Module):
def __init__(self, output_size, intermediate_size, encoding_size):
super().__init__()
self.decoder = nn.Sequential(
nn.ConvTranspose1d(50,100, 1),
nn.BatchNorm1d(100),
nn.ReLU(True),
nn.Dropout(0.2),
nn.ConvTranspose1d(100, 500, 1),
nn.BatchNorm1d(500),
nn.Sigmoid())
def forward(self, x):
#x = x.view(1, 1, -1)
x = self.decoder(x)
return x
but it shows me this error
RuntimeError: The size of tensor a (500) must match the size of tensor b (64) at non-singleton dimension 1
Sincerely, I do not know what’s my problem here? ? can you help me please ?