<jupyter_start><jupyter_text><jupyter_code>import torch
from torch import nn
if torch.cuda.is_available():
  device = torch.device('cuda')
else:
  device = torch.device('cpu')
print(device)
import torch
from torch import nn
if torch.cuda.is_available():
  device = torch.device('cuda')
else:
  device = torch.device('cpu')
print(device)
from sklearn import datasets
diabetes = datasets.load_diabetes()
data = diabetes.data
target = diabetes.target
class diabetesRegression(nn.Module):
  def __init__(self, input_size, hidden_size, out_size):
    super(diabetesRegression, self).__init__()
    self.hidden  = nn.Linear(input_size, hidden_size)
    self.relu    = nn.ReLU()
    self.out     = nn.Linear(hidden_size, out_size)
    self.softmax = nn.Softmax(dim=-1)

  def forward(self, X):
    feature = self.relu(self.hidden(X))
    output  = self.softmax(self.out(feature))
    return output

input_size  = data.shape[1]
hidden_size = 32
out_size    = 1
net = diabetesRegression(input_size, hidden_size, out_size).to(device)
criterion = nn.MSELoss().to(device)
xTensor = torch.from_numpy(data).float().to(device)
yTensor = torch.from_numpy(target).float().to(device)
pred = net(xTensor)
loss = criterion(pred.squeeze(), yTensor)
print(loss.data)<jupyter_output>tensor(28771.2148)
{'fraction_non_alphanumeric': 0.13380281690140844, 'fraction_numerical': 0.010954616588419406, 'mean_word_length': 5.149038461538462, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '458742', 'license': 'MIT', 'n_tokens_mistral': 464, 'n_tokens_neox': 447, 'n_words': 88, 'path': 'Neural_Networks_Regression.ipynb', 'repo_name': 'helder-garcia/neural-networks-practice', 'size': '1278'}