Outputs random values from a truncated normal distribution. The generated values follow a normal distribution with specified mean and standard deviation, except that values whose magnitude is more than 2 standard deviations from the mean are dropped and re-picked. Args: shape
(self, shape,
mean=0.0,
stddev=1.0,
dtype=dtypes.float32,
name=None)
| 420 | self.state.handle, self.algorithm, shape, dtype=dtype) |
| 421 | |
| 422 | def truncated_normal(self, shape, |
| 423 | mean=0.0, |
| 424 | stddev=1.0, |
| 425 | dtype=dtypes.float32, |
| 426 | name=None): |
| 427 | """Outputs random values from a truncated normal distribution. |
| 428 | |
| 429 | The generated values follow a normal distribution with specified mean and |
| 430 | standard deviation, except that values whose magnitude is more than |
| 431 | 2 standard deviations from the mean are dropped and re-picked. |
| 432 | |
| 433 | Args: |
| 434 | shape: A 1-D integer Tensor or Python array. The shape of the output |
| 435 | tensor. |
| 436 | mean: A 0-D Tensor or Python value of type `dtype`. The mean of the |
| 437 | truncated normal distribution. |
| 438 | stddev: A 0-D Tensor or Python value of type `dtype`. The standard |
| 439 | deviation of the normal distribution, before truncation. |
| 440 | dtype: The type of the output. |
| 441 | name: A name for the operation (optional). |
| 442 | |
| 443 | Returns: |
| 444 | A tensor of the specified shape filled with random truncated normal |
| 445 | values. |
| 446 | """ |
| 447 | with ops.name_scope( |
| 448 | name, "truncated_normal", [shape, mean, stddev]) as name: |
| 449 | shape_tensor = _shape_tensor(shape) |
| 450 | mean_tensor = ops.convert_to_tensor(mean, dtype=dtype, name="mean") |
| 451 | stddev_tensor = ops.convert_to_tensor(stddev, dtype=dtype, name="stddev") |
| 452 | rnd = self._truncated_normal(shape_tensor, dtype=dtype) |
| 453 | mul = rnd * stddev_tensor |
| 454 | return math_ops.add(mul, mean_tensor, name=name) |
| 455 | |
| 456 | def _uniform(self, shape, dtype): |
| 457 | return gen_stateful_random_ops.stateful_uniform( |
nothing calls this directly
no test coverage detected