0ca571cb6c0fb465befebcb4e1fccef6efaecda3,capsulelayers.py,Mask,call,#Mask#Any#,43

Before Change


            // the max value in x clipped to 1 and other to 0. Now `mask` is one-hot coding.
            mask = K.clip(x, 0, 1)

        return K.batch_flatten(inputs * mask)  // masked inputs, shape = [None, num_capsule * dim_capsule]

    def compute_output_shape(self, input_shape):
        if type(input_shape[0]) is tuple:  // true label provided

After Change


            x = K.sqrt(K.sum(K.square(inputs), -1))
            // generate the mask which is a one-hot code.
            // mask.shape=[None, n_classes]=[None, num_capsule]
            mask = K.one_hot(indices=K.argmax(x, 1), num_classes=x.get_shape().as_list()[1])

        // inputs.shape=[None, num_capsule, dim_capsule]
        // mask.shape=[None, num_capsule]
        // masked.shape=[None, num_capsule * dim_capsule]
        masked = K.batch_flatten(inputs * K.expand_dims(mask, -1))
        return masked

    def compute_output_shape(self, input_shape):
        if type(input_shape[0]) is tuple:  // true label provided
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: XifengGuo/CapsNet-Keras
Commit Name: 0ca571cb6c0fb465befebcb4e1fccef6efaecda3
Time: 2017-11-24
Author: guoxifeng1990@163.com
File Name: capsulelayers.py
Class Name: Mask
Method Name: call


Project Name: HyperGAN/HyperGAN
Commit Name: 573c3583105fc1f48f485cb606b9d959fec79be2
Time: 2017-01-30
Author: martyn@255bits.com
File Name: hypergan/discriminators/pyramid_nostride_discriminator.py
Class Name:
Method Name: discriminator


Project Name: tensorflow/models
Commit Name: 12714f88ace4f395c3fa61886c699348a4d7e7f7
Time: 2017-10-28
Author: rathodv@google.com
File Name: research/object_detection/meta_architectures/ssd_meta_arch.py
Class Name: SSDMetaArch
Method Name: _batch_decode