Linear module
- class nnodely.layers.linear.Linear(*args, **kwargs)[source]
Represents a Linear relation in the neural network model.
Notes
Note
The Linear relation works along the input dimension (third dimension) of the input tensor. You can find some initialization functions inside the initializer module.
- Parameters:
output_dimension (int, optional) – The output dimension of the Linear relation.
W_init (Callable, optional) – A callable for initializing the weights.
W_init_params (dict, optional) – A dictionary of parameters for the weight initializer.
b_init (Callable, optional) – A callable for initializing the bias.
b_init_params (dict, optional) – A dictionary of parameters for the bias initializer.
W (Parameter or str, optional) – The weight parameter object or name. If not given a new parameter will be auto-generated.
b (bool, str, or Parameter, optional) – The bias parameter object, name, or a boolean indicating whether to use bias. If set to ‘True’ a new parameter will be auto-generated.
dropout (int or float, optional) – The dropout rate. Default is 0.
- relation_name
The name of the relation.
- Type:
str
- W_init
The weight initializer.
- Type:
Callable
- W_init_params
The parameters for the weight initializer.
- Type:
dict
- b_init
The bias initializer.
- Type:
Callable
- b_init_params
The parameters for the bias initializer.
- Type:
dict
- b
The bias parameter object, name, or a boolean indicating whether to use bias.
- Type:
bool, str, or Parameter
- Wname
The name of the weight parameter.
- Type:
str
- bname
The name of the bias parameter.
- Type:
str
- dropout
The dropout rate.
- Type:
int or float
- output_dimension
The output dimension of the Linear relation.
- Type:
int
Examples
Basic usage:
input = Input('in').tw(0.05) relation = Linear(input)
Passing a weight and bias parameter:
input = Input('in').last() weight = Parameter('W', values=[[[1]]]) bias = Parameter('b', values=[[1]]) relation = Linear(W=weight, b=bias)(input)
Parameters initialization:
input = Input('in').last() relation = Linear( b=True, W_init=init_negexp, b_init=init_constant, b_init_params={'value': 1} )(input)
For more examples of how to use the linear module, please refer to the Linear tutorial.