forked from zawagner22/cross-entropy-for-combinatorics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
28 lines (21 loc) · 748 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import torch
import torch.nn as nn
import torch.nn.functional as F
import itertools
class DenseNet(nn.Module):
def __init__(self, widths):
super().__init__()
num_layers = len(widths)
layers = [[nn.Linear(widths[i], widths[i+1]), nn.ReLU()] for i in range(num_layers-2)]
self.layers = [nn.Flatten(1, -1),
*list(itertools.chain(*layers)),
nn.Linear(widths[-2], widths[-1]),
nn.Sigmoid()]
print(self.layers)
self.net = nn.Sequential(*self.layers)
def forward(self, x):
prob = self.net(x)
return prob
class GraphNet:
def __init__(self, graph):
super().__init__()