Beispiel #1
0
        protected internal virtual bool SetDepth(int min = 1)
        {
            // calculate desired position
            var isRoot  = InNodes.NullOrEmpty();
            var desired = isRoot ? 1 : InNodes.Max(n => n.X) + 1;
            var depth   = Mathf.Max(desired, min);

            // no change
            if (depth == X)
            {
                return(false);
            }

            // update
            X = depth;
            return(true);
        }
Beispiel #2
0
 public void Merge(DummyNode that)
 {
     foreach (var n in that.OutNodes)
     {
         if (!OutNodes.Contains(n))
         {
             _outEdges.Add(new Edge <Node, Node>(this, n));
         }
     }
     foreach (var n in that.InNodes)
     {
         if (!InNodes.Contains(n))
         {
             _inEdges.Add(new Edge <Node, Node>(n, this));
         }
     }
 }
Beispiel #3
0
        private void Forward(bool isTraining)
        {
            if (lastOp == Ops.Forward)
            {
                return;
            }

            InNodes.ForEach(N =>
            {
                if (N.lastOp != Ops.Forward)
                {
                    return;
                }
            });

            lastOp = Ops.Forward;

            Layers.ForEach(L => L.Forward(isTraining));
            OutNodes.ForEach(N => N.Forward(isTraining));
        }
Beispiel #4
0
        private void CalcGrads()
        {
            if (lastOp == Ops.CalcGrads)
            {
                return;
            }

            OutNodes.ForEach(N =>
            {
                if (N.lastOp != Ops.CalcGrads)
                {
                    return;
                }
            });

            lastOp = Ops.CalcGrads;

            for (int i = Length - 1; i >= 0; i--)
            {
                Layers[i].CalcGrads();
            }

            InNodes.ForEach(N => N.CalcGrads());
        }