aa968dad320137a31c229be3094c6538fd5ce39c,tensorlayer/layers/core.py,Layer,__call__,#Layer#Any#,203

Before Change



    def __call__(self, prev_layer, **kwargs):

        if self.__class__.__name__ in tl.layers.inputs.__all__:
            // 1. for input layers
            // Input layers should use tf.convert_to_tensor to make sure the inputs is converted into tf.Tensor

            // code in tl 1.0
            // raise RuntimeError("Please use layers in `tl.layers.inputs` to convert Variable/Tensor/Placeholder/Numpy arrays to a TL layer")
            // FIXME: not sure convert_to_tensor here or ask user to do it
            self.inputs = tf.convert_to_tensor(prev_layer)
            self._input_layer = None
            self._built = True
            self.build(self._inputs_shape)
            self.outputs = self.forward(self.inputs, **kwargs)

        elif isinstance(prev_layer, Layer):
            // 2. for normal layer have only 1 input i.e. DenseLayer
            // Hint : list(), dict() is pass by value (shallow), without them,
            // it is pass by reference.

            self.inputs = prev_layer.outputs
            self._input_layer = prev_layer

            if not self._built:
                self.build(self._inputs_shape)
                self._built = True

            self.outputs = self.forward(self.inputs, **kwargs)
            // self._outputs_shape = self.outputs.get_shape().as_list()

            // TODO: need update
            // self._add_layers(prev_layer.all_layers)
            // self._add_weights(self._weights)
            // self._add_weights(prev_layer.all_weights)
            // self._add_dropout_layers(prev_layer.all_drop)

        elif isinstance(prev_layer, list):
            // 3. for layer have multiply inputs i.e. ConcatLayer

            self.inputs = [layer.outputs for layer in prev_layer]
            self._input_layer = prev_layer // FIXME: not sure how to deal with it

            // FIXME: only support concat/elementwise, where build does nothing
            if not self._built:
                self._built = True

            self.outputs = self.forward(self.inputs, **kwargs)

            // TODO: need update
            // self._add_layers(sum([l.all_layers for l in prev_layer], []))
            // self._add_weights(sum([l.all_weights for l in prev_layer], []))
            // self._add_dropout_layers(sum([list(l.all_drop.items()) for l in prev_layer], []))

        else:
            // FIXME: not sure if there is other cases
            pass
            // elif prev_layer is not None:
            //     // 4. tl.models
            //     self._add_layers(prev_layer.all_layers)
            //     self._add_weights(prev_layer.all_weights)
            //     self._add_dropout_layers(prev_layer.all_drop)
            //
            //     if hasattr(prev_layer, "outputs"):
            //         self.inputs = prev_layer.outputs

        return self

    def _release_memory(self):
        """

After Change


        return self._weights

    def __call__(self, inputs, **kwargs):
        if self.__class__.__name__ in tl.layers.inputs.__all__:
            self.inputs = tf.convert_to_tensor(inputs)
        else:
            self.inputs = inputs

        if not self._built:
            self.build(self._inputs_shape)
            self._built = True
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 7

Instances


Project Name: tensorlayer/tensorlayer
Commit Name: aa968dad320137a31c229be3094c6538fd5ce39c
Time: 2019-03-06
Author: rundi_wu@pku.edu.cn
File Name: tensorlayer/layers/core.py
Class Name: Layer
Method Name: __call__


Project Name: keras-team/keras
Commit Name: aac81c29a762fdaef6718bbc4883f208283aac9c
Time: 2018-05-06
Author: bohumir.zamecnik@gmail.com
File Name: keras/engine/saving.py
Class Name:
Method Name: preprocess_weights_for_loading


Project Name: AKSHAYUBHAT/DeepVideoAnalytics
Commit Name: 90c7356471023c1bbeaabbcfff37eba11940bbe4
Time: 2018-08-13
Author: akshayubhat@gmail.com
File Name: server/init_fs.py
Class Name:
Method Name: init_models


Project Name: deepmipt/DeepPavlov
Commit Name: f528c38e26d59b231dd94b87d6603ca243fee766
Time: 2018-02-28
Author: yoptar@gmail.com
File Name: deeppavlov/core/commands/train.py
Class Name:
Method Name: train_model_from_config