-
Notifications
You must be signed in to change notification settings - Fork 0
Kernel implementation #4
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
graceemetz
wants to merge
4
commits into
main
Choose a base branch
from
kernel-implementation
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
Changes from all commits
Commits
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
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
6 changes: 3 additions & 3 deletions
6
doc/04-component-abstract-class/04-component-abstract-class.md
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,7 @@ | ||
| Manifest-Version: 1.0 | ||
| Ant-Version: Apache Ant 1.10.12 | ||
| Created-By: 19.0.1+10-21 (Oracle Corporation) | ||
| Built-By: Paolo Bucci | ||
| Sealed: false | ||
| Built-On: 2023-01-01 10:30:08 | ||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
|
|
||
| /** | ||
| * Interface for additional methods within the Artificial Neuron component. | ||
| * | ||
| * @author Grace Metz | ||
| * | ||
| */ | ||
| public interface Neuron extends NeuronKernel { | ||
|
|
||
| /** | ||
| * Using the sigmoid activation function: an output >= 0.5 means a yes, or | ||
| * the neuron has fired. | ||
| * | ||
| * @return whether the neuron has fired. | ||
| */ | ||
| boolean activate(); | ||
|
|
||
| /** | ||
| * Set an object's weight and ensure they are usable by the neuron. | ||
| * | ||
| * @param value | ||
| * the weight being entered | ||
| */ | ||
| void setWeight(double value); | ||
|
|
||
| /** | ||
| * Sum the weights. | ||
| * | ||
| * @return the sum of the weights. | ||
| */ | ||
| double sum(); | ||
|
|
||
| } |
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,71 @@ | ||
| import components.queue.Queue; | ||
| import components.queue.Queue1L; | ||
|
|
||
| /** | ||
| * {@code Neuron} represented as multiple {@link Queue}s with implementations of | ||
| * primary methods. | ||
| * | ||
| * @convention [$this.inputs is a queue of String inputs] and [$this.weights is | ||
| * a queue of double weights] | ||
| * @correspondence this = ($this.inputs, $this.weights) | ||
| */ | ||
| public class Neuron1 extends NeuronSecondary { | ||
|
|
||
| /** | ||
| * Queue of Strings to represent the values of each input. | ||
| */ | ||
| private Queue<String> inputs; | ||
|
|
||
| /** | ||
| * Queue of values to represent the weights of each input. | ||
| */ | ||
| private Queue<Double> weights; | ||
|
|
||
| /** | ||
| * Creator of initial representation. | ||
| */ | ||
| private void createNewRep() { | ||
| this.inputs = new Queue1L<>(); | ||
| this.weights = new Queue1L<>(); | ||
| } | ||
|
|
||
| /** | ||
| * No-argument constructor. | ||
| */ | ||
| public Neuron1() { | ||
| this.createNewRep(); | ||
| } | ||
|
|
||
| @Override | ||
| public final Queue<Double> weights() { | ||
| return this.weights; | ||
| } | ||
|
|
||
| @Override | ||
| public final Queue<String> inputs() { | ||
| return this.inputs; | ||
| } | ||
|
|
||
| @Override | ||
| public final void setInput(String value) { | ||
| this.inputs.enqueue(value); | ||
| } | ||
|
|
||
| @Override | ||
| public final void clear() { | ||
| this.inputs = this.inputs.newInstance(); | ||
| this.weights = this.weights.newInstance(); | ||
| } | ||
|
|
||
| @Override | ||
| public final Neuron newInstance() { | ||
| Neuron newIn = new Neuron1(); | ||
| return newIn; | ||
| } | ||
|
|
||
| @Override | ||
| public final void transferFrom(Neuron arg0) { | ||
| this.inputs.transferFrom(arg0.inputs); | ||
| this.weights.transferFrom(arg0.weights); | ||
| } | ||
| } | ||
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,46 @@ | ||
| import components.queue.Queue; | ||
| import components.queue.Queue1L; | ||
| import components.standard.Standard; | ||
|
|
||
| /** | ||
| * Interface for the essential methods and values within the Artificial Neuron | ||
| * component. | ||
| * | ||
| * @author Grace Metz | ||
| * | ||
| */ | ||
| public interface NeuronKernel extends Standard<Neuron> { | ||
|
|
||
| /** | ||
| * Queue of Strings to represent the values of each input. | ||
| */ | ||
| Queue<String> inputs = new Queue1L<>(); | ||
|
|
||
| /** | ||
| * Queue of values to represent the weights of each input. | ||
| */ | ||
| Queue<Double> weights = new Queue1L<>(); | ||
|
|
||
| /** | ||
| * Retrieve the weight assigned to the inputs within this node. | ||
| * | ||
| * @return the queue of weight values | ||
| */ | ||
| Queue<Double> weights(); | ||
|
|
||
| /** | ||
| * Return the inputs entered into the neuron. | ||
| * | ||
| * @return the queue of input Strings | ||
| */ | ||
| Queue<String> inputs(); | ||
|
|
||
| /** | ||
| * Ensure that inputs are valid and usable by the neuron. | ||
| * | ||
| * @param value | ||
| * the String value being entered | ||
| */ | ||
| void setInput(String value); | ||
|
|
||
| } |
Oops, something went wrong.
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.
I would take a peek at the previous projects to see how to implement these three methods. They're all okay, but there are better ways to write them (especially this one).