diff options
Diffstat (limited to 'tensorflow/python/ops/init_ops.py')
-rw-r--r-- | tensorflow/python/ops/init_ops.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/tensorflow/python/ops/init_ops.py b/tensorflow/python/ops/init_ops.py index 610feb742e..141fb8c13a 100644 --- a/tensorflow/python/ops/init_ops.py +++ b/tensorflow/python/ops/init_ops.py @@ -1,3 +1,18 @@ +# Copyright 2015 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + """Operations often used for initializing tensors.""" from __future__ import absolute_import from __future__ import division @@ -14,21 +29,21 @@ from tensorflow.python.ops import random_ops # TODO(mrry): PEP8 these. def constant_initializer(value=0.0): - """Returns an initializer that generates Tensors with a single value. + """Returns an initializer that generates tensors with a single value. Args: value: A Python scalar. All elements of the initialized variable will be set to this value. Returns: - An initializer that generates Tensors with a single value. + An initializer that generates tensors with a single value. """ def _initializer(shape, dtype=types.float32): return constant_op.constant(value, dtype=dtype, shape=shape) return _initializer def random_uniform_initializer(minval=0.0, maxval=1.0, seed=None): - """Returns an initializer that generates Tensors with a uniform distribution. + """Returns an initializer that generates tensors with a uniform distribution. Args: minval: a python scalar or a scalar tensor. lower bound of the range @@ -40,14 +55,14 @@ def random_uniform_initializer(minval=0.0, maxval=1.0, seed=None): for behavior. Returns: - An initializer that generates Tensors with a uniform distribution. + An initializer that generates tensors with a uniform distribution. """ def _initializer(shape, dtype=types.float32): return random_ops.random_uniform(shape, minval, maxval, dtype, seed=seed) return _initializer def random_normal_initializer(mean=0.0, stddev=1.0, seed=None): - """Returns an initializer that generates Tensors with a normal distribution. + """Returns an initializer that generates tensors with a normal distribution. Args: mean: a python scalar or a scalar tensor. Mean of the random values @@ -59,7 +74,7 @@ def random_normal_initializer(mean=0.0, stddev=1.0, seed=None): for behavior. Returns: - An initializer that generates Tensors with a normal distribution. + An initializer that generates tensors with a normal distribution. """ def _initializer(shape, dtype=types.float32): return random_ops.random_normal(shape, mean, stddev, dtype, seed=seed) @@ -68,7 +83,7 @@ def random_normal_initializer(mean=0.0, stddev=1.0, seed=None): def truncated_normal_initializer(mean=0.0, stddev=1.0, seed=None): """Returns an initializer that generates a truncated normal distribution. - These values are similar to values from a random_normal_initializer + These values are similar to values from a `random_normal_initializer` except that values more than two standard deviations from the mean are discarded and re-drawn. This is the recommended initializer for neural network weights and filters. @@ -83,7 +98,7 @@ def truncated_normal_initializer(mean=0.0, stddev=1.0, seed=None): for behavior. Returns: - An initializer that generates Tensors with a truncated normal + An initializer that generates tensors with a truncated normal distribution. """ def _initializer(shape, dtype=types.float32): |