Instantiates a variable with values drawn from a normal distribution. Arguments: shape: Tuple of integers, shape of returned Keras variable. mean: Float, mean of the normal distribution. scale: Float, standard deviation of the normal distribution. dtype: String, dtype of r
(shape, mean, scale, dtype=None, name=None,
seed=None)
| 1474 | |
| 1475 | @keras_export('keras.backend.random_normal_variable') |
| 1476 | def random_normal_variable(shape, mean, scale, dtype=None, name=None, |
| 1477 | seed=None): |
| 1478 | """Instantiates a variable with values drawn from a normal distribution. |
| 1479 | |
| 1480 | Arguments: |
| 1481 | shape: Tuple of integers, shape of returned Keras variable. |
| 1482 | mean: Float, mean of the normal distribution. |
| 1483 | scale: Float, standard deviation of the normal distribution. |
| 1484 | dtype: String, dtype of returned Keras variable. |
| 1485 | name: String, name of returned Keras variable. |
| 1486 | seed: Integer, random seed. |
| 1487 | |
| 1488 | Returns: |
| 1489 | A Keras variable, filled with drawn samples. |
| 1490 | |
| 1491 | Example: |
| 1492 | ```python |
| 1493 | # TensorFlow example |
| 1494 | >>> kvar = K.random_normal_variable((2,3), 0, 1) |
| 1495 | >>> kvar |
| 1496 | <tensorflow.python.ops.variables.Variable object at 0x10ab12dd0> |
| 1497 | >>> K.eval(kvar) |
| 1498 | array([[ 1.19591331, 0.68685907, -0.63814116], |
| 1499 | [ 0.92629528, 0.28055015, 1.70484698]], dtype=float32) |
| 1500 | ``` |
| 1501 | """ |
| 1502 | if dtype is None: |
| 1503 | dtype = floatx() |
| 1504 | tf_dtype = dtypes_module.as_dtype(dtype) |
| 1505 | if seed is None: |
| 1506 | # ensure that randomness is conditioned by the Numpy RNG |
| 1507 | seed = np.random.randint(10e8) |
| 1508 | value = init_ops.random_normal_initializer( |
| 1509 | mean, scale, dtype=tf_dtype, seed=seed)(shape) |
| 1510 | return variable(value, dtype=dtype, name=name) |
| 1511 | |
| 1512 | |
| 1513 | @keras_export('keras.backend.count_params') |