-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/relu #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nereuxofficial
wants to merge
48
commits into
sakex:main
Choose a base branch
from
Nereuxofficial:feature/relu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/relu #18
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
2b43c07
Implemented GUI for snake
Nereuxofficial d115927
Merge remote-tracking branch 'origin/main' into snake
Nereuxofficial 7de0a29
Removed GUI & Increased Generations & the number of snakes
Nereuxofficial 73a0039
Snakes can no longer rotate forever
Nereuxofficial 1e652d4
Removed unnecessary dependency
Nereuxofficial 0d4e38e
Simplified Snake example
Nereuxofficial 8332522
Added Benchmark library
Nereuxofficial 86f38b3
Remove unused imports
Nereuxofficial 00f0316
Cleanups
Nereuxofficial ee9861b
Derive Hash instead of implementing it
Nereuxofficial 04a9a22
Cleanups
Nereuxofficial e559d99
Further Cleanups & Refactoring
Nereuxofficial 5ceaf25
Update README.md
Nereuxofficial 70d905c
Refactoring & Docs
Nereuxofficial 81ef41c
Better function name
Nereuxofficial 39c9bcd
Cleanups
Nereuxofficial a3f2428
Added comments
Nereuxofficial 0e2c83d
Reworded comments
Nereuxofficial 459c4a3
Removed unnecessary .gitignore
Nereuxofficial 9f5555a
Fancier Badges
Nereuxofficial 2b68ac6
Fixed accidental Crtl+V
Nereuxofficial 144bb77
Fixed accidental Paste
Nereuxofficial 7208831
Split Github Workflows
b30052e
Removed unnecessary code
Nereuxofficial b7541d4
WIP: Fixing serialization
Nereuxofficial 4946362
Revert changes to Topology::to_serde_string
Nereuxofficial f9bf105
Fixed Serialization and Benchmarks
Nereuxofficial d756682
Fixed Benchmark and included snakes.json
Nereuxofficial 47f6733
Topology::to_string(&self) now uses to_string_pretty
Nereuxofficial b0f54b0
Removed duplicate functions & Created separate json for benchmarking
Nereuxofficial f4a9a2e
Restructured some Snake code
Nereuxofficial 157395e
Snake Example simplified and with par_iter
Nereuxofficial b041c17
Updated dependencies
Nereuxofficial 7b8e69a
Refactoring
Nereuxofficial 72252be
Refactoring
Nereuxofficial 64d8cf8
Added wasm32 build to Tests
Nereuxofficial 0ef3e2c
Added wasm32 build to Tests
Nereuxofficial 89114e9
Fix Github Actions wasm32 build
Nereuxofficial f834f57
Added benchmarks for math functions.
9d44b1a
Merge remote-tracking branch 'sakex/main'
Nereuxofficial cf0ab0c
WIP: Trying out the relu function
Nereuxofficial db104fd
Extended benchmarks
Nereuxofficial 8c4f130
Merge remote-tracking branch 'upstream/main'
Nereuxofficial 65d9744
Added relu as a feature to the crate
Nereuxofficial 9431476
Merge branch 'main' into feature/relu
Nereuxofficial 04c52e8
Fixed merge conflicts
Nereuxofficial 6625c8e
PR Changes
Nereuxofficial a2fe01e
Fixed build errors
Nereuxofficial File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //! Contains benchmarks of the functions stored in neural_network::functions. | ||
| use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; | ||
| use neat_gru::neural_network::functions::*; | ||
|
|
||
| extern crate neat_gru; | ||
| fn input_data() -> impl IntoIterator<Item = f32>{ | ||
| let size: f32 = 0.3518392; | ||
| (0..20).map(move |i| size * i as f32) | ||
| } | ||
| fn bench_sigmoid(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("Sigmoid Function"); | ||
| input_data().into_iter().for_each(|s|{ | ||
| group.bench_with_input(BenchmarkId::from_parameter(s), &s, |b, size| { | ||
| b.iter(|| fast_sigmoid(*size)) | ||
| }); | ||
| }); | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn bench_tanh(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("Tanh Function"); | ||
| input_data().into_iter().for_each(|s|{ | ||
| group.bench_with_input(BenchmarkId::from_parameter(s), &s, |b, s| { | ||
| b.iter(|| fast_tanh(*s)) | ||
| }); | ||
| }); | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn bench_relu(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("Relu Function"); | ||
| input_data().into_iter().for_each(|s|{ | ||
| group.bench_with_input(BenchmarkId::from_parameter(s), &s, |b, s| { | ||
| b.iter(|| re_lu(*s)) | ||
| }); | ||
| }); | ||
| group.finish(); | ||
| } | ||
|
|
||
| fn comparison(c: &mut Criterion) { | ||
| let mut group = c.benchmark_group("Relu vs Sigmoid"); | ||
| input_data().into_iter().for_each(|s| | ||
| { | ||
| group.bench_with_input(BenchmarkId::new("Sigmoid", s), &s, | ||
| |b, size| b.iter(|| fast_sigmoid(*size))); | ||
| group.bench_with_input(BenchmarkId::new("Relu", s), &s, | ||
| |b, s| b.iter(|| re_lu(*s))); | ||
| group.bench_with_input(BenchmarkId::new("Tanh", s), &s, | ||
| |b, s| b.iter(|| fast_tanh(*s))); | ||
| }); | ||
| group.finish(); | ||
| } | ||
|
|
||
| criterion_group! { | ||
| name = benches; | ||
| config = Criterion::default(); | ||
| targets = bench_tanh, bench_sigmoid, bench_relu, comparison | ||
| } | ||
| criterion_main!(benches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| mod connection_gru; | ||
| mod connection_relu; | ||
| mod connection_sigmoid; | ||
| mod functions; | ||
| pub(crate) mod functions; | ||
| mod neuron; | ||
| mod nn; | ||
| pub mod nn; | ||
| pub mod nn_trait; | ||
|
|
||
| pub use nn::*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| use std::fmt::Display; | ||
|
|
||
| use num::Float; | ||
|
|
||
| use crate::topology::Topology; | ||
|
|
||
| pub trait NN<T>: Sized | ||
| where | ||
| T: Float + std::ops::AddAssign + Display + Send, | ||
| { | ||
| /// Instantiates a new Neural Network from a `Topology` | ||
| /// | ||
| /// # Safety | ||
| /// | ||
| /// If the Topology is ill-formed, it will result in pointer overflow. | ||
| /// Topologies generated by this crate are guaranteed to be safe. | ||
| unsafe fn from_topology(topology: &Topology<T>) -> Self; | ||
|
|
||
| /// Deserializes a serde serialized Topology into a neural network | ||
| fn from_string(serialized: &str) -> Self { | ||
| let top = Topology::from_string(serialized); | ||
| unsafe { Self::from_topology(&top) } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have options for tanh,sigmoid and relu for all possible activations as it wil bias the output