Package crino :: Module module :: Class Linear
[hide private]
[frames] | no frames]

Class Linear

source code


A Linear module computes its outputs as a linear transformation of its inputs. It has two params : W ∈ ℳnout × nin(ℝ) and b ∈ ℝnout.

The outputs expression can be written as follows :  = W × x + b

Instance Methods [hide private]
 
__init__(self, nOutputs, nInputs=None, W_init=None, b_init=None)
Constructs a new Linear module.
source code
 
prepareParams(self, W=None, b=None)
Initializes the W and b params of the Linear module.
source code
 
prepareOutput(self)
Computes the linear relation  = W × x + b
source code

Inherited from Standalone: prepareGeometry

Inherited from Module: criterionFunction, forward, forwardFunction, holdFunction, linkInputs, linkModule, prepare, prepareBackup, restoreFunction, save, trainFunction

Instance Variables [hide private]
ndarray W_init
The initialization matrix for W.
ndarray b_init
The initialization vector for b.
TensorVariable W
The symbolic linear transformation matrix.
TensorVariable b
The symbolic offset vector.

Inherited from Module: backupParams, inputs, nInputs, nOutputs, outputs, params, prepared

Method Details [hide private]

__init__(self, nOutputs, nInputs=None, W_init=None, b_init=None)
(Constructor)

source code 
Constructs a new Linear module.
Parameters:
  • nOutputs (int) - The outputs size.
  • nInputs (int) - The inputs size.
  • W_init (ndarray) - The initialization matrix for W.
  • b_init (ndarray) - The initialization vector for b.
Overrides: Module.__init__

prepareParams(self, W=None, b=None)

source code 
Initializes the W and b params of the Linear module.
Parameters:
  • W (TensorVariable) - If provided, the Linear module will use W as a shared parameter from another module.
  • b (TensorVariable) - If provided, the Linear module will use b as a shared parameter from another module.
Overrides: Module.prepareParams

Attention: W\_init and b\_init values will be ignored if existing W and b are passed, since they have already been initialized in another module.

prepareOutput(self)

source code 
Computes the linear relation  = W × x + b
Overrides: Module.prepareOutput