sugartensor.sg_initializer module¶
-
sugartensor.sg_initializer.
constant
(name, shape, value=0, dtype=tf.float32, summary=True)[source]¶ Creates a tensor variable of which initial values are value and shape is shape.
- Args:
name: The name of new variable. shape: A tuple/list of integers or an integer.
If shape is an integer, it is converted to a list.- value: A Python scalar. All elements of the initialized variable
- will be set to this value. Default is 0.
dtype: The data type. Only floating point types are supported. Default is float32. summary: If True, add this constant to tensor board summary.
- Returns:
- A Variable.
-
sugartensor.sg_initializer.
external
(name, value, dtype=tf.float32, summary=True)[source]¶ Creates a tensor variable of which initial values are value.
For example,
` external("external", [3,3,1,2]) => [3. 3. 1. 2.] `
- Args:
- name: The name of new variable. value: A constant value (or list) of output type dtype. dtype: The type of the elements of the resulting tensor. summary: If True, add this constant to tensor board summary.
- Returns:
- A Variable. Has the same contents as value of dtype.
-
sugartensor.sg_initializer.
glorot_uniform
(name, shape, scale=1, dtype=tf.float32, summary=True)[source]¶ See [Glorot & Bengio. 2010.](http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf)
- Args:
- name: The name of new variable shape: A tuple/list of integers. scale: A Python scalar. Scale to initialize. Default is 1. dtype: The data type. Default is float32. summary: If True, add this constant to tensor board summary.
- Returns:
- A Variable.
-
sugartensor.sg_initializer.
he_uniform
(name, shape, scale=1, dtype=tf.float32, summary=True)[source]¶ See [He et al. 2015](http://arxiv.org/pdf/1502.01852v1.pdf)
- Args:
- name: The name of new variable shape: A tuple/list of integers. scale: A Python scalar. Scale to initialize. Default is 1. dtype: The data type. Default is float32. summary: If True, add this constant to tensor board summary.
- Returns:
- A Variable.
-
sugartensor.sg_initializer.
identity
(name, dim, scale=1, dtype=tf.float32, summary=True)[source]¶ Creates a tensor variable of which initial values are of an identity matrix.
Note that the default value of scale (=0.05) is different from the min/max values (=0.0, 1.0) of tf.random_uniform_initializer.
For example,
``` identity(“identity”, 3, 2) => [[2. 0. 0.]
[0. 2. 0.] [0. 0. 2.]]- Args:
- name: The name of new variable. dim: An int. The size of the first and second dimension of the output tensor. scale: A Python scalar. The value on the diagonal. dtype: The type of the elements of the resulting tensor. summary: If True, add this constant to tensor board summary.
- Returns:
- A 2-D Variable.
-
sugartensor.sg_initializer.
orthogonal
(name, shape, scale=1.1, dtype=tf.float32, summary=True)[source]¶ Creates a tensor variable of which initial values are of an orthogonal ndarray.
See [Saxe et al. 2014.](http://arxiv.org/pdf/1312.6120.pdf)
- Args:
- name: The name of new variable. shape: A tuple/list of integers. scale: A Python scalar. dtype: Either float32 or float64. summary: If True, add this constant to tensor board summary.
- Returns:
- A Variable.
-
sugartensor.sg_initializer.
uniform
(name, shape, scale=0.05, dtype=tf.float32, summary=True)[source]¶ Creates a tensor variable of which initial values are random numbers based on uniform distribution.
Note that the default value of scale (=0.05) is different from the min/max values (=0.0, 1.0) of tf.random_uniform_initializer.
- Args:
name: The name of the new variable. shape: A tuple/list of integers or an integer.
If shape is an integer, it’s converted to a list.scale: A Python scalar. All initial values should be in range [-scale, scale). Default is .05. dtype: The data type. Only floating point types are supported. Default is float32. summary: If True, add this constant to tensor board summary.
- Returns:
- A Variable.