복잡한 가중치의 분포를 스무딩하게 만들어준다.
import torch
import torch.nn as nn
class MyModel(nn.Module):
def __init__(self):
super(MyModel, self).__init__()
self.fc1 = nn.Linear(128, 64)
self.bn1 = nn.BatchNorm1d(64) # 배치 정규화 레이어
self.fc2 = nn.Linear(64, 10)
def forward(self, x):
x = self.fc1(x)
x = self.bn1(x) # 배치 정규화 적용
x = torch.relu(x)
x = self.fc2(x)
return x
model = MyModel()