• Creates a new variable with the provided initial value.

    const x = tf.variable(tf.tensor([1, 2, 3]));
    x.assign(tf.tensor([4, 5, 6]));

    x.print();

    Type Parameters

    • R extends Rank

    Parameters

    • initialValue: Tensor<R>

      Initial value for the tensor.

    • Optional trainable: boolean

      If true, optimizers are allowed to update it.

    • Optional name: string

      Name of the variable. Defaults to a unique id.

    • Optional dtype: keyof DataTypeMap

      If set, initialValue will be converted to the given type.

    Returns Variable<R>

    Doc

Generated using TypeDoc