def parameter_count(self, input_shape): """Get the number of model parameters in this layer.""" depth = convnet.depth_to_space_channels(input_shape[-1], self.block_size) count = self.patch_size * self.patch_size * input_shape[-1] * depth if self.bias: count += depth return count
def output_shape(self, input_shape): """Determine the output shape given the input shape.""" depth = convnet.depth_to_space_channels(input_shape[-1], self.block_size) shape = convnet.image_output_size( input_shape, (self.patch_size, self.patch_size, input_shape[3], depth), (1, 1), self.padding ) return convnet.depth_to_space_shape(shape, {"block_size":self.block_size})
def construct(self, input_shape): """Construct the convnet the operations for this layer.""" depth = convnet.depth_to_space_channels(input_shape[-1], self.block_size) op = convnet.create_conv( (self.patch_size, self.patch_size), (1, 1), input_shape[3], depth, self.bias, self.padding, self.initializer.construct() ) op.set_l2_factor(self.l2_factor) yield op yield convnet.create_depth_to_space(self.block_size)