i am new to the forum and to Pytorch, i want to predict 3 real values Y1, Y2 & Y3 from input values X1, X2…X10 using the below model, but i get the error in title:
File “/home/abdelmoula/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py”, line 833, in linear
if input.dim() == 2 and bias is not None:
AttributeError: ‘numpy.ndarray’ object has no attribute ‘dim’
Can you please on what is wrong ? thank you
########################
MODEL:
import pandas as pd
import torch
from torch.autograd import Variable
learning_rate = 1e-2
optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
for t in range(5000):
y_pred = model(x)
loss = loss_fn(y_pred, y)
print(t, loss.data[0])
Hello Team,
I have the same problem in the implementation of the AutoEncoder
this is the class AE:
import torch.nn as nn
import torch
class AE(nn.Module):
def init(self):
super(AE,self).init()
input_shape=256
self.encoder_hidden_layer=nn.Linear(input_shape,10)
self.encoder_output_layer=nn.Linear(10,2)
self.decoder_hidden_layer=nn.Linear(2,10)
self.decoder_output_layer=nn.Linear(10,input_shape)
self.encoder_hidden_layer1 = nn.Linear(input_shape, 10)
self.encoder_output_layer1= nn.Linear(10, 2)
self.decoder_hidden_layer1 = nn.Linear(2, 10)
self.decoder_output_layer1= nn.Linear(10, input_shape)
def forward(self,features):
activation=self.encoder_hidden_layer(features)
activation=torch.relu(activation)
code=self.encoder_output_layer(activation)
code = torch.relu(code)
activation=self.decoder_hidden_layer(code)
activation=torch.relu(activation)
activation=self.decoder_output_layer(activation)
reconstructed=torch.sigmoid(activation)
thanks but still the same error,
this is my model : i want that the output of the DCT is the input of the first autoencoder and the out put of this autoencoder is the input of the second autoencoder
if name==‘main’:
Load the training and testing dataset separately by calling the function for each of their root folder locations
Thanks for you, but a new error has appeared after the change of the array to tensor and the change i made in the implementation of the AE
this is a stack trace of the error and the AE
This error is raised, if you try to pass a Size object to as an argument to the layer creation:
x = torch.randn(10, 10)
nn.Linear(x.size(), 10)
> TypeError: new(): argument 'size' must be tuple of ints, but found element of type torch.Size at pos 2
Based on your previous code snippet, input_shape should be defined as input_shape = 256, so I assume you might have changed the code in the meantime.
PS: Please don’t post screenshots, but paste the code directly and wrap it into three backticks ```.
ok , but i want that the shape of DCT function be the input of the autoencoder that’s why i define the input_shape as the the output of DCT.shape
what advises you can give me and thanks a lot