kaixin:

days_elapsed = 4


I have 368 temperature measurements with the corresponding water-level, I am taking a block of four consecutive (the sliding window) readings, which would leave me with 362 = 365 - 3 training samples = batch size, right.  just like what you have mentioned bfore
input: [[day1’s temp, day2’s temp, day3’s temp, day 4’s temp],
[day2’s temp, day3’s temp, day4’s temp, day 5’s temp],
[day3’s temp, day4’s temp, day5’s temp, day 6’s temp],
[day4’s temp, day5’s temp, day6’s temp, day 7’s temp]]
.
.
.
[day362’s temp, day363’s temp, day364’s temp, day 365’s temp]]
target: [[day4’s water level],
[day5’s water level],
[day6’s water level],
[day7’s water level]]
.
.
.
[day365’s water level]]
and ture, the data is list but i convert it  like this and here is my code (but the problem that I get now is “RuntimeError: size mismatch, m1: [1 x 365], m2: [1 x 10]”)
book= pd.ExcelFile(“path.xlsx”)
sheet=book.parse(“sheetname”)
print(sheet)
Input=sheet[‘R’]
Target=sheet[‘MWL’]
Input = torch.tensor(Input)
Target = torch.tensor(Target)
batch_size = 362
days_elapsed = 4
learning_rate=0.01
epochs=5
input_size= 1
hidden_size=10
output_size=1
class LoadData(Dataset):
def init(self, inputs, targets, days_elapsed):
assert len(inputs) == len(targets)
self.inputs = inputs
self.targets = targets
self.days_elapsed = days_elapsed
def __len__(self):
    return len(self.targets) - self.days_elapsed + 1

def __getitem__(self, idx):
    return {'inputs': [self.inputs[i] for i in range(idx + self.days_elapsed)],
            'target': self.targets[idx + self.days_elapsed - 1]}

train_dataset = LoadData (Input, Target, days_elapsed)
train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=true)
print(train_loader)
len(train_loader)
class Net(nn.Module):
def init(self, input_size, hidden_size, output_size):
    super(Net, self).__init__()
    self.fc1 = nn.Linear(input_size, hidden_size)
    self.fc2 = nn.Linear(hidden_size, output_size)
    self.Sigmoid = nn.Sigmoid()


def forward(self, x):
    x = self.fc1(x)
    x = self.Sigmoid(x)
    x = self.fc2(x)
    x = self.Sigmoid(x)
    return x

FFNN = Net(input_size, hidden_size, output_size)
print(FFNN)
criterion = nn.MSELoss()
optimizer = torch.optim.SGD(FFNN.parameters(), lr=learning_rate)
Training the FNN Model
for epoch in range (epochs):
for batch_idx, (inputtensor, targettensor) in enumerate(train_loader):
inputtensor = Variable(Input)
targettensor = Variable(Target)
optimizer.zero_grad()
FFNN_output= FFNN(inputtensor)
    loss = criterion(FFNN_output, targettensor)
    loss.backward()
    optimizer.step()
    
    #print out some results every time a certain number of iterations is reached
    if (i+1) % 100 == 0
        print('Epoch [%d/%d], Step [%d/%d], Loss: %.4f'
             %(epoch+1, num_epochs, i+1, len(train_dataset)//batch_size, loss.data[0]))