Class VarianceScaling
Initializer capable of adapting its scale to the shape of weights. With distribution="normal", samples are drawn from a truncated normal distribution centered on zero, with stddev = sqrt(scale / n) where n is:
- number of input units in the weight tensor, if mode = "fan_in"
- number of output units, if mode = "fan_out"
- average of the numbers of input and output units, if mode = "fan_avg"
With distribution = "uniform", samples are drawn from a uniform distribution within[-limit, limit], with limit = sqrt(3 * scale / n).
Inheritance
Inherited Members
Namespace: SiaNet.Initializers
Assembly: SiaNet.dll
Syntax
public class VarianceScaling : BaseInitializer
Constructors
| Improve this Doc View SourceVarianceScaling(Single, String, String, Nullable<Int32>)
Initializes a new instance of the VarianceScaling class.
Declaration
public VarianceScaling(float scale = 1F, string mode = "fan_in", string distribution = "normal", int? seed = default(int? ))
Parameters
Type | Name | Description |
---|---|---|
System.Single | scale | Scaling factor (positive float). |
System.String | mode | One of "fan_in", "fan_out", "fan_avg". |
System.String | distribution | Random distribution to use. One of "normal", "uniform". |
System.Nullable<System.Int32> | seed | Used to seed the random generator. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Scale must be positive value |
Properties
| Improve this Doc View SourceDistribution
Random distribution to use. One of "normal", "uniform".
Declaration
public string Distribution { get; set; }
Property Value
Type | Description |
---|---|
System.String | The distribution. |
Mode
One of "fan_in", "fan_out", "fan_avg".
Declaration
public string Mode { get; set; }
Property Value
Type | Description |
---|---|
System.String | The mode. |
Scale
Scaling factor (positive float).
Declaration
public float Scale { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The scale. |
Seed
Used to seed the random generator.
Declaration
public int? Seed { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> | The seed. |
Methods
| Improve this Doc View SourceGenerate(Int64[])
Generates a tensor with specified shape.
Declaration
public override Tensor Generate(params long[] shape)
Parameters
Type | Name | Description |
---|---|---|
System.Int64[] | shape | The shape of the tensor. |
Returns
Type | Description |
---|---|
Tensor |