Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nschaetti committed Apr 6, 2017
1 parent f51bd3a commit 0ee474f
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 0 deletions.
4 changes: 4 additions & 0 deletions echotorch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

import dataset
import nn
import tools
Empty file.
Empty file.
Empty file added echotorch/dataset/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions echotorch/nn/FreeRunReservoir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
#
# File : echotorch/nn/FreeRunReservoir.py
# Description : Implement the Echo State Network neural network with feed backs.
# Date : 6th of April, 2017
#
# This file is part of EchoTorch. EchoTorch is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Nils Schaetti <nils.schaetti@unine.ch>

21 changes: 21 additions & 0 deletions echotorch/nn/LeakyReservoir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
#
# File : echotorch/nn/LeakyReservoir.py
# Description : Implement the Echo State Network neural network with leaky units.
# Date : 6th of April, 2017
#
# This file is part of EchoTorch. EchoTorch is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Nils Schaetti <nils.schaetti@unine.ch>

56 changes: 56 additions & 0 deletions echotorch/nn/Reservoir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
#
# File : echotorch/nn/Reservoir.py
# Description : Implement the Echo State Network neural network.
# Date : 6th of April, 2017
#
# This file is part of EchoTorch. EchoTorch is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Nils Schaetti <nils.schaetti@unine.ch>

import torch
import torch.nn as nn


# Echo State Network Reservoir module
class Reservoir(nn.Module):

def __init__(self, input_features, reservoir_features, output_features, bias=True):
# Params
self.input_features = input_features
self.reservoir_features = reservoir_features
self.output_features = output_features

# Parameters
self.weight = nn.Parameter(torch.Tensor(output_features))

# If bias
if bias:
self.bias = nn.Parameter(torch.Tensor(reservoir_features))
else:
self.register_parameter('bias', None)
# end if

# Initialize reservoir weights randomly
self.w = torch.Tensor.random_(-1, 2)

# end __init__


# Forward
def forward(self, input):
return Reservoir()(input, self.weight, self.bias)
# end forward

# end Reservoir
3 changes: 3 additions & 0 deletions echotorch/nn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

from Reservoir import *

Empty file added echotorch/tools/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


import echotorch.nn


if __name__ == "__main__":

# Create Echo State Network
esn = echotorch.nn.Reservoir(input_features=40, reservoir_features=100, output_features=10, bias=True)

# end if

0 comments on commit 0ee474f

Please sign in to comment.