Skip to content

Commit

Permalink
rename neural-network to cames, fixed neat visualization on sphere pr…
Browse files Browse the repository at this point in the history
…oblems
  • Loading branch information
samyhaff committed Jun 6, 2024
1 parent dfc51aa commit 4f16704
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn get_algorithm(algorithm_type: AlgorithmType, resolution: usize, neurons: usiz
let neat = Neat::new(config);
Algorithm::Neat(neat)
}
AlgorithmType::NeuralNetwork => {
AlgorithmType::Cmaes => {
let toml_config: &str = toml_config.as_deref().unwrap();
let network_config: NeuralNetworkConfig = toml::from_str(&toml_config).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ pub enum AlgorithmType {
Oneplusonena,
Bna,
Neat,
NeuralNetwork,
Cmaes,
}
28 changes: 26 additions & 2 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ impl State {

Algorithm::Neat(_) | Algorithm::NeuralNetwork(_) => {
match &self.problem {
Benchmark::Classification(points) | Benchmark::SphereClassification(points) => {
// for now, draw outputs
Benchmark::Classification(points) => {
for (point, _) in points {
let output = self.alg.evaluate(&point);
// gradient from red to green
Expand All @@ -232,6 +231,31 @@ impl State {
)?;
}
}
Benchmark::SphereClassification(points) => {
for (point, _) in points {
let output = self.alg.evaluate(&point);
// gradient from red to green
let color = graphics::Color::new(
1.0 - output as f32,
output as f32,
0.0,
1.0,
);
let point = self.polar_to_canvas(&point);
// mesh.circle(
// graphics::DrawMode::stroke(8.0),
// point,
// 20.0,
// 0.1,
// color,
// )?;
mesh.rectangle(
graphics::DrawMode::fill(),
graphics::Rect::new(point.x - 5., point.y - 5., 10.0, 10.0),
color,
)?;
}
}

Benchmark::PoleBalancing => (),
Benchmark::DatasetClassification(_, _) => (),
Expand Down

0 comments on commit 4f16704

Please sign in to comment.