transform - transform layers

The file yann.layers.transform.py contains the definition for the transformation layers.

This code is used to rotate the images given some angles between [0,1].

Obliging License, credit and conditions for Lasagne: Some part of the file was directly reproduced from the Lasagne code base.

Author: Anchit Agarwal

LICENSE

Copyright (c) 2014-2015 Lasagne contributors

Lasagne uses a shared copyright model: each contributor holds copyright over their contributions to Lasagne. The project versioning records all such contribution and copyright details. By contributing to the Lasagne repository through pull-request, comment, or otherwise, the contributor releases their content to the license and copyright terms herein.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class yann.layers.transform.dropout_rotate_layer(input, input_shape, id, rng=None, dropout_rate=0.5, angle=None, borrow=True, verbose=2)[source]

This class is the typical dropout neural hidden layer and batch normalization layer. Called by the add_layer method in network class.

Parameters:
  • input – An input theano.tensor variable. Even theano.shared will work as long as they are in the following shape mini_batch_size, channels, height, width
  • verbose – similar to the rest of the toolbox.
  • input_shape(mini_batch_size, input_size)
  • angle – value from [0,1]
  • borrowtheano borrow, typically True.
  • rng – typically numpy.random.
  • dropout_rate0.5 is the default.

Notes

Use dropout_rotate_layer.output and dropout_rotate_layer.output_shape from this class.

class yann.layers.transform.rotate_layer(input, input_shape, id, angle=None, borrow=True, verbose=2)[source]

This is a rotate layer. This takes a layer and an angle (rotation normalized in [0,1]) as input and rotates the batch of images by the specified rotation parameter.

Parameters:
  • input – An input theano.tensor variable. Even theano.shared will work as long as they are in the following shape mini_batch_size, channels, height, width
  • verbose – similar to the rest of the toolbox.
  • input_shape(mini_batch_size, input_size)
  • angle – value from [0,1]
  • borrowtheano borrow, typically True.
  • input_params – Supply params or initializations from a pre-trained system.