ff62eb251b04b8301e71aee970bdb157f2649fa9,keras/layers/local.py,LocallyConnected2D,build,#LocallyConnected2D#Any#,295

Before Change


        self.W = self.init(self.W_shape, name="{}_W".format(self.name))

        if self.bias:
            self.b = K.zeros((output_row, output_col, nb_filter), name="{}_b".format(self.name))
            self.trainable_weights = [self.W, self.b]
        else:
            self.trainable_weights = [self.W]

        self.regularizers = []
        if self.W_regularizer:
            self.W_regularizer.set_param(self.W)
            self.regularizers.append(self.W_regularizer)
        if self.bias and self.b_regularizer:
            self.b_regularizer.set_param(self.b)
            self.regularizers.append(self.b_regularizer)
        if self.activity_regularizer:
            self.activity_regularizer.set_layer(self)
            self.regularizers.append(self.activity_regularizer)

        self.constraints = {}
        if self.W_constraint:
            self.constraints[self.W] = self.W_constraint
        if self.bias and self.b_constraint:
            self.constraints[self.b] = self.b_constraint

        if self.initial_weights is not None:
            self.set_weights(self.initial_weights)
            del self.initial_weights
        self.built = True

After Change


        self.initial_weights = weights
        super(LocallyConnected2D, self).__init__(**kwargs)

    def build(self, input_shape):
        output_shape = self.get_output_shape_for(input_shape)
        if self.dim_ordering == "th":
            _, nb_filter, output_row, output_col = output_shape
            input_filter = input_shape[1]
        elif self.dim_ordering == "tf":
            _, output_row, output_col, nb_filter = output_shape
            input_filter = input_shape[3]
        else:
            raise Exception("Invalid dim_ordering: " + self.dim_ordering)

        self.output_row = output_row
        self.output_col = output_col
        self.W_shape = (output_row * output_col, self.nb_row * self.nb_col * input_filter, nb_filter)

        self.W = self.add_weight(self.W_shape,
                                 initializer=self.init,
                                 name="{}_W".format(self.name),
                                 regularizer=self.W_regularizer,
                                 constraint=self.W_constraint)
        if self.bias:
            self.b = self.add_weight((output_row, output_col, nb_filter),
                                     initializer="zero",
                                     name="{}_b".format(self.name),
                                     regularizer=self.b_regularizer,
                                     constraint=self.b_constraint)
        else:
            self.b = None

        if self.initial_weights is not None:
            self.set_weights(self.initial_weights)
            del self.initial_weights
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 6

Non-data size: 85

Instances


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/local.py
Class Name: LocallyConnected2D
Method Name: build


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/convolutional.py
Class Name: Convolution2D
Method Name: build


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/convolutional.py
Class Name: Convolution3D
Method Name: build


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/convolutional.py
Class Name: Convolution1D
Method Name: build


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/local.py
Class Name: LocallyConnected2D
Method Name: build


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/core.py
Class Name: Dense
Method Name: build


Project Name: keras-team/keras
Commit Name: ff62eb251b04b8301e71aee970bdb157f2649fa9
Time: 2016-12-14
Author: francois.chollet@gmail.com
File Name: keras/layers/core.py
Class Name: MaxoutDense
Method Name: build