Example #1
0
    def __init__(self):
        super(CIFAR_Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 64, 3, 1)
        self.conv1b = nn.Conv2d(64, 64, 3, 1)
        self.conv2 = nn.Conv2d(64, 128, 3, 1)
        self.conv2b = nn.Conv2d(128, 128, 3, 1)

        self.fc1 = nn.Linear(128 * 5 * 5, 512)
        self.fc2 = nn.Linear(512, 128)
        self.fc3 = nn.Linear(128, 10)
 def __init__(self, vocab_size: int):
     super().__init__()
     # Embedding dimension: vocab_size + <unk>, <pad>, <eos>, <sos>
     self.emb = crb.Embedding(vocab_size + 4, 100)
     self.lstm = crb.LSTM(100, 100)
     self.pool = crb.AvgPool1d(256)
     self.fc1 = crb.Linear(100, 2)
Example #3
0
 def __init__(self, vocab_size, embedding_dim, pad_idx):
     super().__init__()
     # we will fix the dimensions here for the purpose of our experiments 
     hidden_dim = 256
     output_dim = 1
     n_layers = 1 
     self.embedding = nn.Embedding(vocab_size, embedding_dim, padding_idx = pad_idx)
     
     self.rnn = nn.LSTM(embedding_dim, 
                        hidden_dim, 
                        num_layers=n_layers)
     
     self.fc = nn.Linear(hidden_dim, output_dim)
Example #4
0
    def __init__(self,
                 input_size=(1, 32, 32),
                 n_layers=2,
                 n_channels=25,
                 factor=1.0,
                 kernel_size=5):
        super().__init__()
        self.input_size = input_size

        # Layers grow at factor `factor`
        conv_layers = []
        for i in range(n_layers):
            channels_in = int(n_channels * (factor ** (i - 1))) if i > 0 else \
                input_size[0]
            channels_out = int(n_channels * (factor**i))

            conv_layers.append(
                nn.Conv2d(channels_in, channels_out, kernel_size, 1,
                          padding=2))
        self.conv_layers = nn.ModuleList(conv_layers)
        self.conv_output = self.conv_block(torch.randn(1, *input_size)).size(1)

        self.fc = nn.Linear(self.conv_output, 10)
Example #5
0
 def __init__(self):
     super(Net, self).__init__()
     self.conv1 = nn.Conv2d(1, 32, 3, 1)
     self.conv2 = nn.Conv2d(32, 64, 3, 1)
     self.fc1 = nn.Linear(9216, 128)
     self.fc2 = nn.Linear(128, 10)
 def __init__(self, **_):
     super().__init__()
     self.fc1 = crb.Linear(104, 1)
 def __init__(self, **_):
     super().__init__()
     self.fc1 = crb.Linear(104, 50)
     self.fc2 = crb.Linear(50, 2)
 def __init__(self, **_):
     super().__init__()
     self.conv1 = crb.Conv2d(1, 16, 8, 2, padding=3)
     self.conv2 = crb.Conv2d(16, 32, 4, 2)
     self.fc1 = crb.Linear(32 * 4 * 4, 32)
     self.fc2 = crb.Linear(32, 10)