(
initialValue: Tensor, trainable = true, name?: string,
dtype?: DataType)
| 854 | } |
| 855 | |
| 856 | makeVariable( |
| 857 | initialValue: Tensor, trainable = true, name?: string, |
| 858 | dtype?: DataType): Variable { |
| 859 | name = name || this.nextVariableId().toString(); |
| 860 | if (dtype != null && dtype !== initialValue.dtype) { |
| 861 | initialValue = initialValue.cast(dtype); |
| 862 | } |
| 863 | const v = new Variable(initialValue, trainable, name, this.nextTensorId()); |
| 864 | if (this.state.registeredVariables[v.name] != null) { |
| 865 | throw new Error(`Variable with name ${v.name} was already registered`); |
| 866 | } |
| 867 | this.state.registeredVariables[v.name] = v; |
| 868 | this.incRef(v, this.backend); |
| 869 | return v; |
| 870 | } |
| 871 | |
| 872 | trackTensor(a: Tensor, backend: KernelBackend): void { |
| 873 | this.state.numTensors++; |
nothing calls this directly
no test coverage detected