public void TestCheckModelThrowsActionHybrid() { var model = ModelLoader.Load(hybridONNXModel); var brainParameters = GetHybridBrainParameters(); brainParameters.ActionSpec = new ActionSpec(3, new[] { 3 }); // Invalid discrete action size var errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0], sensor_20_22_3.CreateSensors()[0] }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.ActionSpec = ActionSpec.MakeDiscrete(2); // Missing continuous action errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0], sensor_20_22_3.CreateSensors()[0] }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelThrowsActionDiscrete(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(discreteNNModel) : ModelLoader.Load(discreteONNXModel); var brainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); brainParameters.ActionSpec = ActionSpec.MakeDiscrete(3, 3); // Invalid action var errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0] }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.ActionSpec = ActionSpec.MakeContinuous(2); // Invalid SpaceType errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0] }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelThrowsVectorObservationContinuous(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(continuousNNModel) : ModelLoader.Load(continuousONNXModel); var brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.VectorObservationSize = 9; // Invalid observation var errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0], sensor_20_22_3.CreateSensors()[0] }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.NumStackedVectorObservations = 2;// Invalid stacking errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0], sensor_20_22_3.CreateSensors()[0] }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelValidRecurrent() { var model = ModelLoader.Load(hybridRecurrV2Model); var num_errors = 0; // A model trained with v2 should not raise errors var validBrainParameters = GetRecurrHybridBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new ISensor[] { sensor_8 }, new ActuatorComponent[0] ); Assert.AreEqual(num_errors, errors.Count()); // There should not be any errors var invalidBrainParameters = GetRecurrHybridBrainParameters(); invalidBrainParameters.ActionSpec = new ActionSpec(1, new int[] { 2, 3 }); errors = BarracudaModelParamLoader.CheckModel( model, invalidBrainParameters, new ISensor[] { sensor_8 }, new ActuatorComponent[0] ); Assert.AreEqual(1, errors.Count()); // 1 continuous action instead of 2 invalidBrainParameters.ActionSpec = new ActionSpec(2, new int[] { 3, 2 }); errors = BarracudaModelParamLoader.CheckModel( model, invalidBrainParameters, new ISensor[] { sensor_8 }, new ActuatorComponent[0] ); Assert.AreEqual(1, errors.Count()); // Discrete action branches flipped }
public void TestCheckModelRank2() { var model = ModelLoader.Load(rank2ONNXModel); var validBrainParameters = GetRank2BrainParameters(); var errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new ISensor[] { sensor_23_20, sensor_10, sensor_8 }, new ActuatorComponent[0] ); Assert.AreEqual(0, errors.Count()); // There should not be any errors errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new ISensor[] { sensor_23_20, sensor_10 }, new ActuatorComponent[0] ); Assert.AreNotEqual(0, errors.Count()); // Wrong number of sensors errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new ISensor[] { new BufferSensor(20, 40, "BufferSensor"), sensor_10, sensor_8 }, new ActuatorComponent[0] ); Assert.AreNotEqual(0, errors.Count()); // Wrong buffer sensor size errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new ISensor[] { sensor_23_20, sensor_10, sensor_10 }, new ActuatorComponent[0] ); Assert.AreNotEqual(0, errors.Count()); // Wrong vector sensor size }
public void TestCheckModelThrowsNoModel() { var brainParameters = GetContinuous2vis8vec2actionBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel(null, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }, new ActuatorComponent[0]); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelValid2() { var model = ModelLoader.Load(discrete1vis0vec_2_3action_recurrModel); var validBrainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel(model, validBrainParameters, new SensorComponent[] { sensor_21_20_3 }); Assert.AreEqual(0, errors.Count()); // There should not be any errors }
public void TestCheckModelValid1() { var model = ModelLoader.Load(continuous2vis8vec2actionModel); var validBrainParameters = GetContinuous2vis8vec2actionBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel(model, validBrainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }); Assert.AreEqual(0, errors.Count()); // There should not be any errors }
public void TestCheckModelThrowsVectorObservation2() { var model = ModelLoader.Load(discrete1vis0vec_2_3action_recurrModel); var brainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); brainParameters.VectorObservationSize = 1; // Invalid observation var errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3 }); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelThrowsVectorObservationDiscrete(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(discreteNNModel) : ModelLoader.Load(discreteONNXModel); var brainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); brainParameters.VectorObservationSize = 1; // Invalid observation var errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new ISensor[] { sensor_21_20_3.CreateSensor() }, new ActuatorComponent[0]); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelValidHybrid() { var model = ModelLoader.Load(hybridONNXModel); var validBrainParameters = GetHybridBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new SensorComponent[] { }, new ActuatorComponent[0] ); Assert.AreEqual(0, errors.Count()); // There should not be any errors }
public void TestCheckModelValidDiscrete(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(discreteNNModel) : ModelLoader.Load(discreteONNXModel); var validBrainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new SensorComponent[] { sensor_21_20_3 }, new ActuatorComponent[0] ); Assert.AreEqual(0, errors.Count()); // There should not be any errors }
public void TestCheckModelValidContinuous(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(continuousNNModel) : ModelLoader.Load(continuousONNXModel); var validBrainParameters = GetContinuous2vis8vec2actionBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }, new ActuatorComponent[0] ); Assert.AreEqual(0, errors.Count()); // There should not be any errors }
public void TestCheckModelThrowsAction2() { var model = ModelLoader.Load(discrete1vis0vec_2_3action_recurrModel); var brainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); brainParameters.VectorActionSize = new int[] { 3, 3 }; // Invalid action var errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3 }); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.VectorActionSpaceType = SpaceType.Continuous;// Invalid SpaceType errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3 }); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelThrowsVectorObservation1() { var model = ModelLoader.Load(continuous2vis8vec2actionModel); var brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.VectorObservationSize = 9; // Invalid observation var errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.NumStackedVectorObservations = 2;// Invalid stacking errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelThrowsAction1() { var model = ModelLoader.Load(continuous2vis8vec2actionModel); var brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.VectorActionSize = new[] { 3 }; // Invalid action var errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }, new ActuatorComponent[0]); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.VectorActionSpaceType = SpaceType.Discrete;// Invalid SpaceType errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }, new ActuatorComponent[0]); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelThrowsActionContinuous(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(continuousNNModel) : ModelLoader.Load(continuousONNXModel); var brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.ActionSpec = ActionSpec.MakeContinuous(3); // Invalid action var errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }, new ActuatorComponent[0]); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.ActionSpec = ActionSpec.MakeDiscrete(3); // Invalid SpaceType errors = BarracudaModelParamLoader.CheckModel(model, brainParameters, new SensorComponent[] { sensor_21_20_3, sensor_20_22_3 }, new ActuatorComponent[0]); Assert.Greater(errors.Count(), 0); }
public void TestCheckModelValidDiscrete(bool useDeprecatedNNModel) { var model = useDeprecatedNNModel ? ModelLoader.Load(discreteNNModel) : ModelLoader.Load(discreteONNXModel); var validBrainParameters = GetDiscrete1vis0vec_2_3action_recurrModelBrainParameters(); var errors = BarracudaModelParamLoader.CheckModel( model, validBrainParameters, new ISensor[] { sensor_21_20_3.CreateSensors()[0] }, new ActuatorComponent[0] ); foreach (var e in errors) { Debug.Log(e.Message); } Assert.Greater(errors.Count(), 0); // There should be an error since LSTM v1.x is not supported }
public void TestCheckModelThrowsVectorObservationHybrid() { var model = ModelLoader.Load(hybridONNXModel); var brainParameters = GetHybridBrainParameters(); brainParameters.VectorObservationSize = 9; // Invalid observation var errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new SensorComponent[] { }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); brainParameters = GetContinuous2vis8vec2actionBrainParameters(); brainParameters.NumStackedVectorObservations = 2;// Invalid stacking errors = BarracudaModelParamLoader.CheckModel( model, brainParameters, new SensorComponent[] { }, new ActuatorComponent[0] ); Assert.Greater(errors.Count(), 0); }