Skip to content

Commit a358819

Browse files
committed
tf 4.fucking0
1 parent 2b87217 commit a358819

File tree

20 files changed

+1027
-89
lines changed

20 files changed

+1027
-89
lines changed

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "phoenix_gui"
33
version = "0.1.0"
44
edition = "2021"
5+
default-run = "phoenix_gui"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

@@ -43,6 +44,7 @@ special-fun = { version = "0.2.0" }
4344
csv = "1.3.0"
4445
bincode = "1.3.3"
4546
lz4-compression = "0.7.0"
47+
phoenix-rec = "0.2.5"
4648

4749
[features]
4850
#default = ["blas", "gui"]

src/bin/cov_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ai::data::get_data;
1+
use phoenix_gui::data::get_data;
22

33
fn covariance(x: Vec<f64>, y: Vec<f64>) -> f64 {
44
let x_mean = x.iter().sum::<f64>() / x.len() as f64;

src/bin/mnist_read_test.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::fs::File;
22
use std::io::Write;
33
use std::path::Path;
44
use std::process::exit;
5+
56
use lz4_compression::compress::compress;
7+
68
use phoenix_gui::data_sets::mnist::MNist;
7-
use phoenix_gui::data_sets::TestSet;
89

910
fn main() {
1011
let mut data_set = MNist::default();
@@ -15,7 +16,10 @@ fn main() {
1516
// let decompressed_data = decompress(&compressed_data).unwrap();
1617
println!("Size after compression: {} bytes", compressed_data.len());
1718
// write to file
18-
write_to_file(&"./src/resources/mnist_data_compressed.bin".to_string(), compressed_data);
19+
write_to_file(
20+
&"./src/resources/mnist_data_compressed.bin".to_string(),
21+
compressed_data,
22+
);
1923
write_to_file(&"./src/resources/mnist_data.bin".to_string(), encoded);
2024
// MNist::print_data(data_set.train_input);
2125
}
@@ -41,4 +45,4 @@ pub fn write_to_file(filename: &String, content: Vec<u8>) {
4145
exit(1);
4246
}
4347
};
44-
}
48+
}

src/bin/mnist_run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ fn main() {
1313
};
1414
let mut mnist = MNist::default();
1515
mnist.run(config);
16-
}
16+
}

src/bin/nn_test.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1+
use phoenix_gui::matrix::Matrix;
12

2-
3-
use ai::matrix::Matrix;
4-
5-
6-
use ai::neural_network::NeuralNetwork;
3+
use phoenix_gui::neural_network::NeuralNetwork;
74
use rand::Rng;
85

9-
10-
116
fn main() {
127
let layer_sizes = vec![2, 400, 20, 4000, 3, 2];
138
println!("layer_sizes: {:?}", layer_sizes);
@@ -72,8 +67,3 @@ fn main() {
7267
(time2 - time1).as_secs()
7368
);
7469
}
75-
76-
#[cfg(any(not(feature = "nn"), not(feature = "gui")))]
77-
fn main() {
78-
println!("This example requires the \"nn\" and \"gui\" features.");
79-
}

src/bin/phoenix_gui.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use phoenix_gui::gui::app::PhoenixGUI;
66

77
const ICON: &[u8; 13450] = include_bytes!("../resources/phoenix_icon.png");
88

9-
109
// When compiling natively:
1110
#[cfg(not(target_arch = "wasm32"))]
1211
fn main() -> eframe::Result<()> {
@@ -38,14 +37,11 @@ fn main() -> eframe::Result<()> {
3837
)
3938
}
4039

41-
42-
4340
#[cfg(target_arch = "wasm32")]
4441
fn main() {
4542
println!("Phoenix is not compiled with GUI support. Try to compile with --all-features.");
4643
}
4744

48-
4945
#[cfg(not(target_arch = "wasm32"))]
5046
fn load_icon() -> eframe::IconData {
5147
let (icon_rgba, icon_width, icon_height) = {

src/data_sets/blue_green.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
21
use crate::data::get_data;
3-
42
use crate::matrix::Matrix;
5-
63
use crate::neural_network::{NNConfig, NeuralNetwork};
74

8-
95
pub fn run(config: NNConfig) {
106
// * 0 - black
117
// * 1 - white

src/data_sets/mnist.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use std::process::exit;
21
use crate::data_sets::TestSet;
32
use crate::matrix::Matrix;
43
use image::RgbImage;
4+
use std::process::exit;
55

66
extern crate image;
77

8+
use crate::neural_network::{NNConfig, NeuralNetwork};
89
use image::{ImageBuffer, Rgb};
910
use lz4_compression::decompress::decompress;
1011
use serde::{Deserialize, Serialize};
11-
use crate::neural_network::{NeuralNetwork, NNConfig};
1212

1313
#[derive(Deserialize, Serialize, Debug)]
1414
pub struct MNist {
@@ -105,7 +105,8 @@ impl MNist {
105105
let value = matrix.get((i * 28 + j) as usize, 0);
106106
let value = (value * 255.0) as u8;
107107
// add col and row to the i j variable
108-
*image.get_pixel_mut(i + col * 28, j + row * 28) = Rgb([value, value, value]);
108+
*image.get_pixel_mut(i + col * 28, j + row * 28) =
109+
Rgb([value, value, value]);
109110
}
110111
}
111112
}
@@ -154,6 +155,11 @@ impl MNist {
154155
nn.command_sender = config.command_sender;
155156
nn.update_interval = config.update_interval;
156157
// todo: dont clone
157-
nn.train_epochs_m(self.train_input.clone(), self.train_target.clone(), config.batch_number, config.epochs);
158+
nn.train_epochs_m(
159+
self.train_input.clone(),
160+
self.train_target.clone(),
161+
config.batch_number,
162+
config.epochs,
163+
);
158164
}
159165
}

src/data_sets/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use crate::matrix::Matrix;
33
pub mod blue_green;
44
pub mod mnist;
55

6-
76
pub trait TestSet {
87
// reads all the data from the file
98
fn read(&mut self) {}
109
// returns the inputs and targets
1110
fn get_data(&self) -> (Vec<Matrix>, Vec<Matrix>, f32) {
1211
(vec![], vec![], 0.0)
1312
}
14-
}
13+
}

0 commit comments

Comments
 (0)