Skip to content
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

[WIP] save previous output and state of RNNs #235

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ Bug fixes:
* Fix error loading unicode filenames (#223)
* Fix ffmpeg unicode filename handling (#236)

API relevant changes:

* Reorder `GRUCell` parameters, to be consistent with all other layers (#235)
* Rename `GRULayer` parameters, to be consistent with all other layers (#235)

Other changes:

* `num_threads` is passed to `ParallelProcessor` in single mode (#217)
* Use `install_requires` in `setup.py` to specify dependencies (#226)
* Allow initialisation of previous/hidden states in RNNs (#235)


Version 0.14.1 (release date: 2016-08-01)
Expand Down
8 changes: 6 additions & 2 deletions madmom/ml/nn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ class NeuralNetwork(Processor):

"""

def __init__(self, layers):
def __init__(self, layers, online=False):
self.layers = layers
self.online = online

def process(self, data):
"""
Expand All @@ -89,13 +90,16 @@ def process(self, data):
Network predictions for this data.

"""
# reset the layers? (online: do not reset, keep the state)
# Note: use getattr to be able to process old models
reset = not getattr(self, 'online', False)
# check the dimensions of the data
if data.ndim == 1:
data = np.atleast_2d(data).T
# loop over all layers
for layer in self.layers:
# activate the layer and feed the output into the next one
data = layer(data)
data = layer(data, reset=reset)
# ravel the predictions if needed
if data.ndim == 2 and data.shape[1] == 1:
data = data.ravel()
Expand Down
Loading