Ejemplo n.º 1
0
 def __init__(self, netParams):
     super(Network, self).__init__()
     # initialize slayer
     slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
     self.slayer = slayer
     # define network functions
     self.conv1 = torch.nn.utils.weight_norm(slayer.conv(2,
                                                         8,
                                                         3,
                                                         padding=1,
                                                         weightScale=20),
                                             name='weight')
     self.conv2 = torch.nn.utils.weight_norm(slayer.conv(8,
                                                         16,
                                                         3,
                                                         padding=1,
                                                         weightScale=100),
                                             name='weight')
     self.conv3 = torch.nn.utils.weight_norm(slayer.conv(16,
                                                         32,
                                                         3,
                                                         padding=1,
                                                         weightScale=100),
                                             name='weight')
     self.fc1 = torch.nn.utils.weight_norm(slayer.dense((10 * 10 * 32),
                                                        512),
                                           name='weight')
     self.fc2 = torch.nn.utils.weight_norm(slayer.dense(512, 5),
                                           name='weight')
     self.pool1 = slayer.pool(2)
     self.pool2 = slayer.pool(2)
Ejemplo n.º 2
0
    def __init__(self, path):
        super(emgFeature, self).__init__()
        netParams = snn.params(path + '/network.yaml')
        # initialize slayer
        slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
        self.slayer = slayer
        # define network functions
        self.fc1 = slayer.dense(16, 128)
        self.fc2 = slayer.dense(128, 128)
        self.fc3 = slayer.dense(128, 5)
        self.delay1 = slayer.delay(128)
        self.delay2 = slayer.delay(128)

        self.fc1.weight.data = torch.FloatTensor(
            np.load(path + '/Trained/fc1Weights.npy').reshape(
                self.fc1.weight.shape))
        self.fc2.weight.data = torch.FloatTensor(
            np.load(path + '/Trained/fc2Weights.npy').reshape(
                self.fc2.weight.shape))
        self.fc3.weight.data = torch.FloatTensor(
            np.load(path + '/Trained/fc3Weights.npy').reshape(
                self.fc3.weight.shape))

        self.delay1.delay.data = torch.FloatTensor(
            np.load(path + '/Trained/delay1.npy').reshape(
                self.delay1.delay.shape))
        self.delay2.delay.data = torch.FloatTensor(
            np.load(path + '/Trained/delay2.npy').reshape(
                self.delay2.delay.shape))
Ejemplo n.º 3
0
 def __init__(self, netParams):
     super(Network, self).__init__()
     # initialize slayer
     slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
     self.slayer = slayer
     # define network functions
     self.fc1 = slayer.dense(Nin, Nhid)
     self.fc2 = slayer.dense(Nhid, Nout)
Ejemplo n.º 4
0
 def __init__(self, netParams):
     super(fusionNet, self).__init__()
     # initialize slayer
     slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
     self.slayer = slayer
     # define network functions
     self.fc1   = slayer.dense(512 + 128, 5)
     self.fc1.weight.data = torch.FloatTensor(np.load('Trained/fc1Weights.npy').reshape(self.fc1.weight.shape))
Ejemplo n.º 5
0
 def __init__(self, netParams):
     super(Network, self).__init__()
     # initialize slayer
     slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
     self.slayer = slayer
     # define network functions
     self.fc1 = slayer.dense((34 * 34 * 2), 512)
     self.fc2 = slayer.dense(512, 10)
Ejemplo n.º 6
0
    def __init__(self, netParams, emgPath, dvsPath):
        super(Network, self).__init__()
        # initialize slayer
        slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
        self.slayer = slayer
        # define network functions
        self.fc1   = torch.nn.utils.weight_norm(slayer.dense(512 + 128, 5), name='weight')

        self.emgNet = emgFeature(emgPath)
        self.dvsNet = dvsFeature(dvsPath)
Ejemplo n.º 7
0
 def __init__(self, netParams):
     super(Network, self).__init__()
     # initialize slayer
     slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
     self.slayer = slayer
     # define network functions
     self.fc1 = torch.nn.utils.weight_norm(slayer.dense(16, 128),
                                           name='weight')
     self.fc2 = torch.nn.utils.weight_norm(slayer.dense(128, 128),
                                           name='weight')
     self.fc3 = torch.nn.utils.weight_norm(slayer.dense(128, 5),
                                           name='weight')
     self.delay1 = slayer.delay(128)
     self.delay2 = slayer.delay(128)
Ejemplo n.º 8
0
 def __init__(self, netParams):
     super(Network, self).__init__()
     # initialize slayer
     slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
     self.slayer = slayer
     # define network functions
     self.conv1 = slayer.conv(2, 16, 5, padding=2, weightScale=10)
     self.conv2 = slayer.conv(16, 32, 3, padding=1, weightScale=50)
     self.pool1 = slayer.pool(4)
     self.pool2 = slayer.pool(2)
     self.pool3 = slayer.pool(2)
     self.fc1 = slayer.dense((8 * 8 * 32), 512)
     self.fc2 = slayer.dense(512, 11)
     self.drop = slayer.dropout(0.1)
Ejemplo n.º 9
0
    def __init__(self, path):
        super(dvsFeature, self).__init__()
        netParams = snn.params(path + '/network.yaml')
        # initialize slayer
        slayer = snn.loihi(netParams['neuron'], netParams['simulation'])
        self.slayer = slayer
        # define network functions
        self.conv1 = slayer.conv( 2,  8, 3, padding=1, weightScale=20)
        self.conv2 = slayer.conv( 8, 16, 3, padding=1, weightScale=100)
        self.conv3 = slayer.conv(16, 32, 3, padding=1, weightScale=100)
        self.fc1   = slayer.dense((10*10*32), 512)
        self.fc2   = slayer.dense(512, 5)
        self.pool1 = slayer.pool(2)
        self.pool2 = slayer.pool(2)

        self.fc1  .weight.data = torch.FloatTensor(np.load(path + '/Trained/fc1Weights.npy'  ).reshape(self.fc1  .weight.shape))
        self.fc2  .weight.data = torch.FloatTensor(np.load(path + '/Trained/fc2Weights.npy'  ).reshape(self.fc2  .weight.shape))
        self.conv1.weight.data = torch.FloatTensor(np.load(path + '/Trained/conv1Weights.npy').reshape(self.conv1.weight.shape))
        self.conv2.weight.data = torch.FloatTensor(np.load(path + '/Trained/conv2Weights.npy').reshape(self.conv2.weight.shape))
        self.conv3.weight.data = torch.FloatTensor(np.load(path + '/Trained/conv3Weights.npy').reshape(self.conv3.weight.shape))
        self.pool1.weight.data = torch.FloatTensor(np.load(path + '/Trained/pool1Weights.npy').reshape(self.pool1.weight.shape))
        self.pool2.weight.data = torch.FloatTensor(np.load(path + '/Trained/pool2Weights.npy').reshape(self.pool2.weight.shape))