* 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)
| 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. |
nothing calls this directly
no test coverage detected