public static VariableTensor Assign(VariableTensor tensor, Matrix <float> value) { VariableTensor t = (VariableTensor)Tensors[tensor.Identifier]; t.Value = value; return(t); }
public static VariableTensor Variable(Matrix <float> initialValue) { VariableTensor newTensor = new VariableTensor(initialValue, typeof(float)); int count = Tensors.Count(t => t.Value is VariableTensor); return((VariableTensor)AddTensor(newTensor, count)); }
public static VariableTensor Variable <T>(T initialValue) { float convertedValue = (float)Convert.ChangeType(initialValue, typeof(float)); VariableTensor newTensor = new VariableTensor(Matrix <float> .Build.Dense(1, 1, convertedValue), typeof(T)); int count = Tensors.Count(t => t.Value is VariableTensor); VariableTensor addedTensor = (VariableTensor)AddTensor(newTensor, count); VariableCollections[GraphKeys.GLOBAL_VARIABLES].Add(addedTensor.Identifier, addedTensor); VariableCollections[GraphKeys.TRAINABLE_VARIABLES].Add(addedTensor.Identifier, addedTensor); return(addedTensor); }
public static VariableTensor Assign(VariableTensor tensor, float value) { Matrix <float> matrixValue = Matrix <float> .Build.Dense(1, 1, value); return(TensorFlow.Assign(tensor, matrixValue)); }