Pytorch Lightning for prediction

Hi All, Can someone please let me know where am i going wrong in the below code. I am getting the below error when i try to execute.

MisconfigurationException: No training_step() method defined. Lightning Trainer expects as minimum a training_step() , train_dataloader() and configure_optimizers() to be defined

import numpy as np ## using again numpy library for Sin function
import torch ## using pytorch
import matplotlib.pyplot as plt
import pytorch_lightning as pl
import torch.optim as optim
from torch import nn
from pytorch_lightning import Trainer
from sklearn.model_selection import train_test_split
import pandas as pd
from import DataLoader

N=1000 ## 1000 samples to be generated
L=1000 ## length of each sample
T=20 ## width of wave
x = np.random.randn(1000)
y = np.sin(x)
df = pd.DataFrame({‘x’:x, ‘y’:y})
train, test = train_test_split(df, test_size=0.2, random_state=42, shuffle=True)
train_features, train_targets = train.drop(target_fields, axis=1), train[target_fields]
test_features, test_targets = test.drop(target_fields, axis=1), test[target_fields]
class MLP(pl.LightningModule):
def init(self):
self.fc1 = nn.Linear(1, 10)
self.fc2 = nn.Linear(10, 1)
def forward(self, x):
x = torch.Relu(self.fc1(x))
x = self.fc2(x)
return x
l_rate = 0.2
mse_loss = nn.MSELoss(reduction = ‘mean’)

def train_dataloader(self):
train_dataset = TensorDataset(torch.tensor(train_features.values).float(), torch.tensor(train_targets[[‘cnt’]].values).float())
train_loader = DataLoader(dataset = train_dataset, batch_size = 128)
return train_loader
def test_dataloader(self):
test_dataset = TensorDataset(torch.tensor(test_features.values).float(), torch.tensor(test_targets[[‘cnt’]].values).float())
test_loader = DataLoader(dataset = test_dataset, batch_size = 128)
return test_loader
def configure_optimizers(self):
return optim.SGD(self.parameters(), lr=l_rate)
def training_step(self, batch, batch_idx):
x, y = batch
logits = self.forward(x)
loss = mse_loss(logits, y)
# Add logging
logs = {‘loss’: loss}
return {‘loss’: loss, ‘log’: logs}
def test_step(self, batch, batch_idx):
x, y = batch
logits = self.forward(x)
loss = mse_loss(logits, y)
correct = torch.sum(logits ==
return {‘test_loss’: loss, ‘test_correct’: correct, ‘logits’: logits}
def test_epoch_end(self, outputs):
avg_loss = torch.stack([x[‘test_loss’] for x in outputs]).mean()
logs = {‘test_loss’: avg_loss}
return {‘avg_test_loss’: avg_loss, ‘log’: logs, ‘progress_bar’: logs }

model = MLP()
trainer = Trainer(max_epochs = 50)