Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Deep Learning/submission_template01.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,45 @@
from torch import nn

def create_model():
# submission_template01.py
import torch.nn as nn

def create_model():
model = nn.Sequential(
nn.Linear(784, 256),
nn.ReLU(),
nn.Linear(256, 16),
nn.ReLU(),
nn.Linear(16, 10)
)
return model
# your code here
# return model instance (None is just a placeholder)

return None

def count_parameters(model):
# submission_template01.py
import torch

def create_model():
model = torch.nn.Sequential(
torch.nn.Linear(784, 256),
torch.nn.ReLU(),
torch.nn.Linear(256, 16),
torch.nn.ReLU(),
torch.nn.Linear(16, 10)
)
return model

def count_parameters(model):
"""
Подсчет общего количества параметров в модели.

:param model:torch.nn.Module - модель, для которой нужно подсчитать параметры
:return: int - общее количество параметров в модели
"""
return sum(p.numel() for p in model.parameters() if p.requires_grad)
# your code here
# return integer number (None is just a placeholder)

Expand Down