Пример #1
0
        public void getFilteredNodesXToY_x_y_and_orphan_y()
        {
            ENV.engine = new Engine();
            var x      = alb.scalar(1);
            var orphan = alb.scalar(0);
            var y      = alb.scalar(2);

            var input1 = new System.Collections.Generic.Dictionary <string, Tensor>();

            input1.Add("x", x);
            input1.Add("orphan", orphan);

            var input2 = new System.Collections.Generic.Dictionary <string, Tensor>();

            input2.Add("x", x);
            TapeNode[] tape = new TapeNode[] {
                new TapeNode()
                {
                    gradient = null
                    , id     = 0
                    , inputs = input1,
                    name     = "node0",
                    output   = y
                }
            };
            var filteredTapeNodes =
                Tape.getFilteredNodesXToY(tape, new Tensor[] { x }, y);

            Assert.AreEqual(filteredTapeNodes.Length, 1);
            AssertTools.TapeNodeIsEqual(filteredTapeNodes[0],

                                        new TapeNode()
            {
                id       = 0,
                name     = "node0",
                gradient = null,
                inputs   = input2,
                output   = y
            }

                                        );
        }