Esempio n. 1
0
        public static VariableTensor Assign(VariableTensor tensor, Matrix <float> value)
        {
            VariableTensor t = (VariableTensor)Tensors[tensor.Identifier];

            t.Value = value;
            return(t);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public static VariableTensor Assign(VariableTensor tensor, float value)
        {
            Matrix <float> matrixValue = Matrix <float> .Build.Dense(1, 1, value);

            return(TensorFlow.Assign(tensor, matrixValue));
        }