예제 #1
0
        public void GenerateVectorObservation()
        {
            var inputTensor = new TensorProxy
            {
                shape = new long[] { 2, 3 }
            };
            const int batchSize  = 4;
            var       agentInfos = GetFakeAgents();
            var       alloc      = new TensorCachingAllocator();
            var       generator  = new VectorObservationGenerator(alloc);

            generator.AddSensorIndex(0);
            generator.AddSensorIndex(1);
            generator.AddSensorIndex(2);
            var agent0 = agentInfos[0];
            var agent1 = agentInfos[1];
            var inputs = new List <AgentInfoSensorsPair>
            {
                new AgentInfoSensorsPair {
                    agentInfo = agent0._Info, sensors = agent0.sensors
                },
                new AgentInfoSensorsPair {
                    agentInfo = agent1._Info, sensors = agent1.sensors
                },
            };

            generator.Generate(inputTensor, batchSize, inputs);
            Assert.IsNotNull(inputTensor.data);
            Assert.AreEqual(inputTensor.data[0, 0], 1);
            Assert.AreEqual(inputTensor.data[0, 2], 3);
            Assert.AreEqual(inputTensor.data[1, 0], 4);
            Assert.AreEqual(inputTensor.data[1, 2], 6);
            alloc.Dispose();
        }
예제 #2
0
        public void GenerateVectorObservation()
        {
            var inputTensor = new TensorProxy
            {
                shape = new long[] { 2, 4 }
            };
            const int batchSize  = 4;
            var       agentInfos = GetFakeAgents(ObservableAttributeOptions.ExamineAll);
            var       alloc      = new TensorCachingAllocator();
            var       generator  = new VectorObservationGenerator(alloc);

            generator.AddSensorIndex(0); // ObservableAttribute (size 1)
            generator.AddSensorIndex(1); // TestSensor (size 0)
            generator.AddSensorIndex(2); // TestSensor (size 0)
            generator.AddSensorIndex(3); // VectorSensor (size 3)
            var agent0 = agentInfos[0];
            var agent1 = agentInfos[1];
            var inputs = new List <AgentInfoSensorsPair>
            {
                new AgentInfoSensorsPair {
                    agentInfo = agent0._Info, sensors = agent0.sensors
                },
                new AgentInfoSensorsPair {
                    agentInfo = agent1._Info, sensors = agent1.sensors
                },
            };

            generator.Generate(inputTensor, batchSize, inputs);
            Assert.IsNotNull(inputTensor.data);
            Assert.AreEqual(inputTensor.data[0, 1], 1);
            Assert.AreEqual(inputTensor.data[0, 3], 3);
            Assert.AreEqual(inputTensor.data[1, 1], 4);
            Assert.AreEqual(inputTensor.data[1, 3], 6);
            alloc.Dispose();
        }
예제 #3
0
        public void GenerateVectorObservation()
        {
            var inputTensor = new Tensor()
            {
                Shape = new long[] { 2, 3 }
            };
            var batchSize  = 4;
            var agentInfos = GetFakeAgentInfos();

            var generator = new VectorObservationGenerator();

            generator.Generate(inputTensor, batchSize, agentInfos);
            Assert.IsNotNull(inputTensor.Data as float[, ]);
            Assert.AreEqual((inputTensor.Data as float[, ])[0, 0], 1);
            Assert.AreEqual((inputTensor.Data as float[, ])[0, 2], 3);
            Assert.AreEqual((inputTensor.Data as float[, ])[1, 0], 4);
            Assert.AreEqual((inputTensor.Data as float[, ])[1, 2], 6);
        }
        public void GenerateVectorObservation()
        {
            var inputTensor = new TensorProxy()
            {
                Shape = new long[] { 2, 3 }
            };
            var batchSize  = 4;
            var agentInfos = GetFakeAgentInfos();
            var alloc      = new TensorCachingAllocator();
            var generator  = new VectorObservationGenerator(alloc);

            generator.Generate(inputTensor, batchSize, agentInfos);
            Assert.IsNotNull(inputTensor.Data);
            Assert.AreEqual(inputTensor.Data[0, 0], 1);
            Assert.AreEqual(inputTensor.Data[0, 2], 3);
            Assert.AreEqual(inputTensor.Data[1, 0], 4);
            Assert.AreEqual(inputTensor.Data[1, 2], 6);
            alloc.Dispose();
        }