-
Notifications
You must be signed in to change notification settings - Fork 125
Create neuron.md #215
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
Closed
Closed
Create neuron.md #215
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --- | ||
| title: Basic Neuron Class | ||
| description: A Python class representing a single artificial neuron that computes the weighted sum of inputs and applies an optional activation function. | ||
| tags: python, machine-learning, neural-networks | ||
| author: jimmydin7 | ||
| --- | ||
|
|
||
| ```py | ||
| import numpy as np | ||
|
|
||
| class Neuron: | ||
| def __init__(self, inputs, weights, bias): | ||
| self.inputs = inputs | ||
| self.weights = weights | ||
| self.bias = bias | ||
|
|
||
| def get_output(self): | ||
| weighted_sum = np.dot(self.inputs, self.weights) + self.bias | ||
| return weighted_sum | ||
|
|
||
| # Example usage | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow proper formatting of snippets, using |
||
| inputs = np.array([1.0, 2.0, 3.0]) | ||
| weights = np.array([0.2, 0.8, -0.5]) | ||
| bias = 2.0 | ||
|
|
||
| neuron = Neuron(inputs, weights, bias) | ||
| output = neuron.get_output() (you can add an activation function) | ||
| print(f"Neuron output: {output}") | ||
| ``` | ||
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.
Please read the guidelines in CONTRIBUTING.md before submitting any snippets, Tags shouldn't contain the name of the language they are coded in
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.
Adding typing to function could be great too !