Exemplo n.º 1
0
 public unsafe void UpdateWeights(Trainable v, Tensor g)
 {
     //Console.WriteLine("Updating The Variable with ID " + v.UniqueId); trainable should have uniqueID
     //Console.Write("Updating The Variable with ID " + v.UniqueId);
     //Console.WriteLine(" -> " + g);
     if (g.Shape.EqualShape(v.Weights.Shape))
     {
         float *ptr_v = (float *)v.Weights.Array;
         float *ptr_m = (float *)g.Array;
         VectorizationFloat.ElementWiseAddAVXBetaB(ptr_v, ptr_m, ptr_v, v.Weights.Shape.TotalSize, -v.LearningRateMultiplier * Hyperparameters.LearningRate);
     }
     else
     {
         throw new DimensionIncompability("The shapes of Variable and Gradient are different!");
     }
 }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (VariableName.Length != 0)
            {
                hash ^= VariableName.GetHashCode();
            }
            if (InitialValueName.Length != 0)
            {
                hash ^= InitialValueName.GetHashCode();
            }
            if (InitializerName.Length != 0)
            {
                hash ^= InitializerName.GetHashCode();
            }
            if (SnapshotName.Length != 0)
            {
                hash ^= SnapshotName.GetHashCode();
            }
            if (saveSliceInfoDef_ != null)
            {
                hash ^= SaveSliceInfoDef.GetHashCode();
            }
            if (IsResource != false)
            {
                hash ^= IsResource.GetHashCode();
            }
            if (Trainable != false)
            {
                hash ^= Trainable.GetHashCode();
            }
            if (Synchronization != global::Tensorflow.VariableSynchronization.Auto)
            {
                hash ^= Synchronization.GetHashCode();
            }
            if (Aggregation != global::Tensorflow.VariableAggregation.None)
            {
                hash ^= Aggregation.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }