in model.py [0:0]
def __init__(self, architecture=[512,512,512], lr=1e-4, n=4, loss=nn.BCEWithLogitsLoss(reduction='none'),
embed_dim=32, topk_count=10, cuda=True):
super().__init__()
self.local_layers = nn.ModuleList()
self.lr = lr
self.topk_count = topk_count
# embed bytes into an embed_dim space
self.embed = nn.Embedding(257, embed_dim, max_norm=1, padding_idx=0)
# several layers of conv1d followed by prelu activations.
# use weight norm instead of batch norm. we're doing weird things that will
# throw off batchnorm.
prev_h = embed_dim
for h in architecture:
self.local_layers.append(nn.utils.weight_norm(nn.Conv1d(prev_h, h, n)))
self.local_layers.append(nn.PReLU(h))
prev_h = h
self.out_layer = nn.Conv1d(prev_h, 1, 1)
self.loss = loss
self.opt = torch.optim.Adam(self.parameters(), lr=self.lr)
self.sched = torch.optim.lr_scheduler.StepLR(self.opt, 1000, 0.95)
self.use_cuda = cuda
if self.use_cuda:
self.cuda()
print(self)