-
Notifications
You must be signed in to change notification settings - Fork 330
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
My changes #684
Open
salah-daddi-nounou
wants to merge
24
commits into
BindsNET:master
Choose a base branch
from
salah-daddi-nounou:my_changes
base: master
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
My changes #684
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3d85fcd
new model added
salah-daddi-nounou b04adc5
ajaccio, plot file
salah-daddi-nounou 8cb0c38
trained and saved the network and assignments tensor
salah-daddi-nounou e947f72
training and testing files
salah-daddi-nounou f014e87
first commit in auguest
salah-daddi-nounou 605dc53
created a test file
salah-daddi-nounou 8cafc88
removed test file
salah-daddi-nounou dd2ff6b
aa
salah-daddi-nounou 61f5774
updated
salah-daddi-nounou 5302f56
changed Modified_PostPre to Bi_sigmoid in all commanding file
salah-daddi-nounou 4c1b7ae
changed Modified_PostPre by Bi_sigmoid everywhere
salah-daddi-nounou 9ae7c12
updated
salah-daddi-nounou 11fef2b
last commit
salah-daddi-nounou 7cbedcf
last commit
salah-daddi-nounou 00bc191
last thing
salah-daddi-nounou 4105060
simulation exp_15 finished
salah-daddi-nounou 1bb3905
added notes.md, and modified eth_mnist.py
salah-daddi-nounou 224985e
changed evaluate and my example, added notes and
salah-daddi-nounou 8e84a06
modified ploting
salah-daddi-nounou adc3955
finished training
salah-daddi-nounou 157fc25
added sacha file
salah-daddi-nounou 26ac436
cleaned scripts
salah-daddi-nounou d5e30a4
clean2
salah-daddi-nounou e5b1687
added variability
salah-daddi-nounou 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 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 |
---|---|---|
|
@@ -22,3 +22,6 @@ logs/* | |
.pytest_cache/* | ||
.vscode/* | ||
data/* | ||
/examples/mnist/*.pt | ||
/examples/mnist/draft* | ||
|
This file contains 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 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 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 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 |
---|---|---|
|
@@ -389,6 +389,11 @@ def _connection_update(self, **kwargs) -> None: | |
""" | ||
Post-pre learning rule for ``Connection`` subclass of ``AbstractConnection`` | ||
class. | ||
|
||
self.source.s : 28 *28 array of 0 and 1 source_s : array converted to 1D vector (784*1) | ||
self.target.x : array of 100 values (~1e-5) target_x : araray (20*5) (values ~1e-9) | ||
source : first layer, target = second layer. | ||
s: spike occurances (0 or 1) for each neuron; x : exp decaying trace | ||
""" | ||
batch_size = self.source.batch_size | ||
|
||
|
@@ -549,6 +554,80 @@ def _conv3d_connection_update(self, **kwargs) -> None: | |
|
||
super().update() | ||
|
||
#=================================================== | ||
class Bi_sigmoid(LearningRule): | ||
# language=rst | ||
""" | ||
Bi_sigmoid STDP rule involving only post-synaptic spiking activity. The weight update | ||
quantity is poisitive if the post-synaptic spike occures shortly after the presynatpic spike, | ||
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. poisitive --> positive |
||
and negative otherwise. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
connection: AbstractConnection, | ||
nu: Optional[Union[float, Sequence[float], Sequence[torch.Tensor]]] = None, | ||
reduction: Optional[callable] = None, | ||
weight_decay: float = 0.0, | ||
**kwargs, | ||
) -> None: | ||
# language=rst | ||
""" | ||
Constructor for ``Bi_sigmoid`` learning rule. | ||
|
||
:param connection: An ``AbstractConnection`` object whose weights the | ||
``Bi_sigmoid`` learning rule will modify. | ||
:param nu: Single or pair of learning rates for pre- and post-synaptic events. It also | ||
accepts a pair of tensors to individualize learning rates of each neuron. | ||
In this case, their shape should be the same size as the connection weights. | ||
:param reduction: Method for reducing parameter updates along the batch | ||
dimension. | ||
:param weight_decay: Coefficient controlling rate of decay of the weights each iteration. | ||
""" | ||
super().__init__( | ||
connection=connection, | ||
nu=nu, | ||
reduction=reduction, | ||
weight_decay=weight_decay, | ||
**kwargs, | ||
) | ||
|
||
assert ( | ||
self.source.traces and self.target.traces | ||
), "Both pre- and post-synaptic nodes must record spike traces." | ||
|
||
if isinstance(connection, (Connection, LocalConnection)): # added: Bi_sigmoid will work only fore these 2 connections | ||
self.update = self._connection_update # rewrites the update rule defined in the base class | ||
else: | ||
raise NotImplementedError( | ||
"This learning rule is not supported for this Connection type." | ||
) | ||
|
||
def _connection_update(self, **kwargs) -> None: | ||
# language=rst | ||
""" | ||
Bi_sigmoid learning rule for ``Connection`` subclass of ``AbstractConnection`` | ||
class. | ||
|
||
self.source.s : 28 *28 array of 0 and 1 source_s : array converted to 1D vector (784*1) | ||
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. Same as before, the description need to be generalize, MNIST is only one way to use BindsNET |
||
self.target.x2 : array of 100 values (~1e-5) target_x2 : araray (20*5) (values ~1e-9) | ||
source : first layer, target = second layer. | ||
s: spike occurances (0 or 1) for each neuron; x2 : bi_sigmoid decaying trace | ||
In this rule we only use the spiking of post (target_s) and the bi_sigmoid trace of pre (source_x2) | ||
""" | ||
batch_size = self.source.batch_size | ||
|
||
# Post-synaptic update. | ||
if self.nu[1].any(): | ||
target_s = (self.target.s.view(batch_size, -1).unsqueeze(1).float() * self.nu[1]) # 100 values of 0&1 | ||
source_x2 = self.source.x2.view(batch_size, -1).unsqueeze(2) # 784 value 1D ( values between -1 and 1) | ||
self.connection.w += self.reduction(torch.bmm(source_x2, target_s), dim=0) | ||
del source_x2, target_s | ||
|
||
super().update() | ||
|
||
|
||
#=================================================== | ||
|
||
class WeightDependentPostPre(LearningRule): | ||
# language=rst | ||
|
This file contains 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
Oops, something went wrong.
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.
This need to be generalized, MNIST is only example.