def _link(self, input_, **kwargs): name = 'flatten' if self.output_shape is None else 'reshape' self.abbreviation = name input_shape = input_.get_shape().as_list() output_shape = ([-1, np.prod(input_shape[1:])] if self.output_shape is None else [-1] + list(self.output_shape)) output = tf.reshape(input_, output_shape, name=name) self.neuron_scale = get_scale(output) return output
def _link(self, *args, **kwargs): # This method is only accessible by Function.__call__ thus a None will # be given as input assert len(args) == 0 and len(kwargs) == 0 input_ = tf.placeholder(dtype=self.dtype, shape=self.input_shape, name=self.name) # Update neuron scale self.neuron_scale = get_scale(input_) # Add input to default collection tf.add_to_collection(pedia.default_feed_dict, input_) # Return placeholder self.place_holder = input_ return input_