5e35bf984690a196063e3eb3fe5807b1475e7d0e,capsulelayers.py,CapsuleLayer,call,#CapsuleLayer#,94

Before Change


            self.bias = K.update(self.bias, self.bias + K.sum(inputs_hat * outputs, [0, -2, -1]))

        // Handling with no routing scenario. Prior bias will always be zero.
        if self.num_routing == 0:
            c = K.softmax(self.bias)
            c_expand = K.expand_dims(K.expand_dims(K.expand_dims(c, 2), 2), 0)
            outputs = squash(K.sum(c_expand * inputs_hat, 1, keepdims=True))

        return K.reshape(outputs, [-1, self.num_capsule, self.dim_vector])

    def compute_output_shape(self, input_shape):
        return tuple([None, self.num_capsule, self.dim_vector])

After Change


            outputs = squash(K.sum(c * inputs_hat, 1, keepdims=True))

            // last iteration needs not compute bias which will not be passed to the graph any more anyway.
            if i != self.num_routing - 1:
                self.bias += K.sum(inputs_hat * outputs, -1, keepdims=True)

        return K.reshape(outputs, [-1, self.num_capsule, self.dim_vector])

    def compute_output_shape(self, input_shape):
        return tuple([None, self.num_capsule, self.dim_vector])
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: XifengGuo/CapsNet-Keras
Commit Name: 5e35bf984690a196063e3eb3fe5807b1475e7d0e
Time: 2017-11-01
Author: guoxifeng1990@163.com
File Name: capsulelayers.py
Class Name: CapsuleLayer
Method Name: call


Project Name: utkuozbulak/pytorch-cnn-visualizations
Commit Name: 697e7fa4f4a6e45566843adc24b126165b817ac0
Time: 2019-05-03
Author: utku.ozbulak@gmail.com
File Name: src/misc_functions.py
Class Name:
Method Name: save_image


Project Name: scikit-optimize/scikit-optimize
Commit Name: 4af750bec058da0cf5d4a3245a443549b9d7fd33
Time: 2016-04-05
Author: manojkumarsivaraj334@gmail.com
File Name: skopt/gp_opt.py
Class Name:
Method Name: acquisition