How to use the chainer.functions.relu function in chainer

To help you get started, we’ve selected a few chainer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chainer / chainer / tests / chainer_tests / training_tests / updaters_tests / test_multiprocess_parallel_updater.py View on Github external
def __call__(self, x, t):
        h = chainer.functions.relu(self.conv(x))
        y = self.fc(h)

        self.loss = chainer.functions.softmax_cross_entropy(y, t)
        self.accuracy = chainer.functions.accuracy(y, t)

        return self.loss
github mitmul / chainer-cifar10 / models / NIN.py View on Github external
def __call__(self, x, t):
        h = F.relu(self.mlpconv1(x))
        h = F.max_pooling_2d(h, 3, stride=2)
        h = F.dropout(h, ratio=0.5, train=self.train)

        h = F.relu(self.mlpconv2(h))
        h = F.average_pooling_2d(h, 3, stride=2)
        h = F.dropout(h, ratio=0.5, train=self.train)

        h = self.mlpconv3(h)
        h = F.average_pooling_2d(h, h.data.shape[2])
        self.y = F.reshape(h, (x.data.shape[0], 10))
        self.pred = F.softmax(self.y)

        self.loss = F.softmax_cross_entropy(self.y, t)
        self.accuracy = F.accuracy(self.y, t)

        if self.train:
            return self.loss
        else:
            return self.pred
github mitmul / chainer-faster-rcnn / lib / models / ResNet50.py View on Github external
def __call__(self, x, train):
        h = F.relu(self.bn1(self.conv1(x), test=not train))
        h = F.relu(self.bn2(self.conv2(h), test=not train))
        h = self.bn3(self.conv3(h), test=not train)

        return F.relu(h + x)
github crystal-method / Looking-to-Listen / network.py View on Github external
#a = F.relu(self.bn7(self.conv7(a)))
        #a = F.relu(self.bn8(self.conv8(a)))
        a = F.relu(self.bn9(self.conv9(a)))
        a = F.relu(self.bn10(self.conv10(a)))
        a = F.relu(self.bn11(self.conv11(a)))
        a = F.relu(self.bn12(self.conv12(a)))
        #a = F.relu(self.bn13(self.conv13(a)))
        #a = F.relu(self.bn14(self.conv14(a)))
        a = F.relu(self.bn15(self.conv15(a)))
        a = F.concat([a[:,i,:,:] for i in range(a.shape[1])], axis=2)[:,xp.newaxis,:,:]
        import numpy as np
        
        # ===== Visual Streams ===== #
        b = F.relu(self.bn_1(self.conv_1(face1)))
        b = F.relu(self.bn_2(self.conv_2(b)))
        b = F.relu(self.bn_3(self.conv_3(b)))
        b = F.relu(self.bn_4(self.conv_4(b)))
        b = F.relu(self.bn_5(self.conv_5(b)))
        #b = F.relu(self.bn_6(self.conv_6(b)))
        b = F.resize_images(b, (N, 1))
        
        c = F.relu(self.bn_1(self.conv_1(face2)))
        c = F.relu(self.bn_2(self.conv_2(c)))
        c = F.relu(self.bn_3(self.conv_3(c)))
        c = F.relu(self.bn_4(self.conv_4(c)))
        c = F.relu(self.bn_5(self.conv_5(c)))
        #c = F.relu(self.bn_6(self.conv_6(c)))
        c = F.resize_images(c, (N, 1))
        
        # ===== Fusion Stream ===== #
        x = F.concat((b, c))
        x = F.transpose(x, (0,3,2,1))
github neka-nat / inv_rl / max_ent_deep_irl.py View on Github external
def __call__(self, x):
        h1 = F.relu(self.l1(x))
        h2 = F.relu(self.l2(h1))
        return self.l3(h2)
github mitmul / chainer-faster-rcnn / lib / models / ResNet50.py View on Github external
def __call__(self, x, train):
        h = F.relu(self.bn1(self.conv1(x), test=not train))
        h = F.relu(self.bn2(self.conv2(h), test=not train))
        h = self.bn3(self.conv3(h), test=not train)

        return F.relu(h + x)
github sisl / Chimp / chimp / run_atari.py View on Github external
def __call__(self, s, action_history):
        h1 = F.relu(self.l1(s/255.0))
        h2 = F.relu(self.l2(h1))
        h3 = F.relu(self.l3(h2))
        h4 = F.relu(self.l4(h3))
        output = self.l5(h4)
        return output
github pfnet-research / chainer-compiler / scripts / nin.py View on Github external
def forward(self, x, t):
        h = F.max_pooling_2d(F.relu(self.mlpconv1(x)), 3, stride=2)
        h = F.max_pooling_2d(F.relu(self.mlpconv2(h)), 3, stride=2)
        h = F.max_pooling_2d(F.relu(self.mlpconv3(h)), 3, stride=2)
        h = self.mlpconv4(F.dropout(h))
        h = F.reshape(F.average_pooling_2d(h, 6), (len(x), 1000))

        #loss = F.softmax_cross_entropy(h, t)
        loss = self.softmax_cross_entropy(h, t)
        if self.compute_accuracy:
            chainer.report({'loss': loss, 'accuracy': F.accuracy(h, t)}, self)
        else:
            chainer.report({'loss': loss}, self)
        return loss