Of course. Here is the code:
import torch
from torch import Tensor
from torch.nn import Linear, L1Loss, MSELoss, functional as F
from torch.optim import SGD, Adam, RMSprop, Rprop
from torch.autograd import Variable
import numpy as np
import matplotlib.pyplot as plt

# parameters
num_epochs = 10
learning_rate = 0.1

# net architecture
class Net(torch.nn.Module):
	def __init__(self):
		super(Net, self).__init__()
		self.fc1 = Linear(1, 50)
		self.fc2 = Linear(50, 1)
		
	def forward(self, x):
		sigmoid = torch.nn.Sigmoid()
		x = self.fc1(x)
		x = sigmoid(x)
		x = self.fc2(x)
		return x
	
model = Net()

# define the loss function
critereon = L1Loss()

# define the optimizer
optimizer = Rprop(model.parameters(), lr=learning_rate)

# load data
data = np.loadtxt("/Users/arun/Desktop/JHU/sapling/rust/sa_ecoli.key.row.sample", usecols=(0,1),skiprows=0, delimiter=" ")
data = data.T

# turn into a ist of lists
X = np.array([[i]for i in data[0]])
y = np.array([[i]for i in data[1]])

# generate residual

# compute gradient
dX = X[len(X)-1][0] - X[0][0]
# print(dX)
dy = y[len(y)-1][0] - y[0][0]
# print(dy)
m = dy/dX
c = y[0][0] - X[0][0]*m

# compute residual values
res = []
for idx in range(len(X)):
	lineVal = X[idx][0] * m + c
	trueVal = y[idx][0]
	resVal = lineVal - trueVal
	res.append([resVal])

# scale data
res = (res - np.min(res))/np.ptp(res)

# plt.plot(X,y)
# plt.show()
# plt.plot(X, res)
# plt.show()

# store the predictions during training
predictions = []

# create our training loop
for epoch in range(num_epochs):
	epoch_loss = 0
	predictions = []
	
	for ix in range(len(X)):
		y_pred = model(Variable(Tensor(X[ix])))
		# print(X[ix], res[ix], y_pred.item())
		predictions.append(y_pred.item())
	
		loss = critereon(y_pred, Variable(Tensor(res[ix])))
		epoch_loss += loss.data.item()
	
		optimizer.zero_grad()
		loss.backward()
		optimizer.step()

	epoch_loss = epoch_loss/len(X)
	print("Epoch: {} Loss: {}".format(epoch, epoch_loss))
	# print("Epoch: {}".format(epoch))


plt.plot(X,predictions)
plt.plot(X,res)
plt.show()

model.eval()

preds = []
for idx in range(len(X)):
	pred = model(Variable(Tensor(X[idx])))
	# print(X[idx], res[idx], pred.item())
	preds.append(pred.item())

plt.plot(X,preds)
plt.plot(X,res)
plt.show()

The data is here:
https://github.com/arun96/random/blob/master/sa_ecoli.key.row.sample 1
Any help would be greatly appreciated - I’m at my wits end when it comes to understanding this.