Код IT Загрузка примера кода…

Python main.py

import torch.nn as nn

class TinyNet(nn.Module):
    def __init__(self, n_in: int, n_hidden: int, n_out: int):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(n_in, n_hidden),
            nn.ReLU(),
            nn.Linear(n_hidden, n_out),
        )

    def forward(self, x):
        return self.net(x)

model = TinyNet(n_in=10, n_hidden=32, n_out=2).to(device)

import torch.nn as nn

class TinyNet(nn.Module):
    def __init__(self, n_in: int, n_hidden: int, n_out: int):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(n_in, n_hidden),
            nn.ReLU(),
            nn.Linear(n_hidden, n_out),
        )

    def forward(self, x):
        return self.net(x)

model = TinyNet(n_in=10, n_hidden=32, n_out=2).to(device)