MCPcopy
hub / github.com/tensorflow/tfjs / constructor

Method constructor

tfjs-layers/src/variables.ts:58–74  ·  view source on GitHub ↗

* Construct Variable from a `tf.Tensor`. * * If not explicitly named, the Variable will be given a name with the * prefix 'Variable'. Variable names are unique. In the case of name * collision, suffixies '_ ' will be added to the name. * * @param val Initial value of the Variab

(
      val: Tensor, dtype: DataType = 'float32',
      name = DEFAULT_VARIABLE_NAME_PREFIX, trainable = true,
      constraint: Constraint = null)

Source from the content-addressed store, hash-verified

56 * @throws ValueError if `name` is `null` or `undefined`.
57 */
58 constructor(
59 val: Tensor, dtype: DataType = 'float32',
60 name = DEFAULT_VARIABLE_NAME_PREFIX, trainable = true,
61 constraint: Constraint = null) {
62 this.dtype = dtype == null ? 'float32' : dtype;
63 this.shape = val.shape;
64 this.id = getNextUniqueTensorId();
65
66 name = name == null ? DEFAULT_VARIABLE_NAME_PREFIX : name;
67 this.originalName = getScopedTensorName(name);
68 this.name = getUniqueTensorName(this.originalName);
69
70 this.trainable_ = trainable;
71 this.constraint = constraint;
72
73 this.val = tfc.variable(val, this.trainable_, this.name, this.dtype);
74 }
75
76 /**
77 * Get a snapshot of the Variable's value.

Callers

nothing calls this directly

Calls 4

getNextUniqueTensorIdFunction · 0.90
getScopedTensorNameFunction · 0.90
getUniqueTensorNameFunction · 0.90
variableMethod · 0.80

Tested by

no test coverage detected