Files
hw3_cnns/model.py
T
2026-11-27 17:11:37 +01:00

25 lines
813 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import torch
import torch.nn as nn
import torch.nn.functional as F
def conv_block(in_ch, out_ch):
"""2× (konvoluce 3×3 -> BatchNorm -> ReLU). Výška a šířka se nemění."""
# ===== TODO 2a =====
raise NotImplementedError("TODO 2a")
class MyModel(nn.Module):
def __init__(self, input_size=None, hidden_size=None, output_size=30, embedding_dim=128):
# input_size a hidden_size se nepoužívají, ale opravující je při vytváření modelu předává
super().__init__()
# ===== TODO 2b: vrstvy =====
def forward(self, x):
"""x [B, 3, 64, 64] -> (species [B, 30], masks [B, 1, 64, 64], embeddings [B, 128])"""
# ===== TODO 2c =====
raise NotImplementedError("TODO 2c")
def get_embedding(self, x):
return self.forward(x)[2]