nmheim / torsk Goto Github PK
View Code? Open in Web Editor NEWAn echo state network (ESN) for video prediction
An echo state network (ESN) for video prediction
It's a bit awkward to address every parameter by name, as is needed when represented as fields in an object. For example, updating parameter values on the command line is much easier, if I could do
def update_params(params,args):
for i in range(1,len(args),2):
[key,value] = args[i:i+2];
params[key] = eval(value)
Then the default values can sit in the json file, but it's quick to supply alternate values without having to change the json or source code.
Currently input maps forget their shapes after being flattened, making plot_iteration need to guess a nice square. Better to keep the natural shape and use that for plotting.
maybe add forgetting to internal states?
Something along these lines:
class sparse_matrix_from_dense():
def __init__(self,Adense,nz_per_row):
self.ix_row, self.ix_col = np.nonzero(Adense);
self.nz_per_row = nz_per_row
self.values = Adense[self.ix_row,self.ix_col]
class sparse_matrix():
def __init__(self,values,nz_per_row,ix_row,ix_col):
self.values = values
self.nz_per_row = nz_per_row
self.ix_row = ix_row
self.ix_col = ix_col
def sparse_dense_mm(A,X):
AXv = A.values[:,None]*X[A.ix_col,:];
return np.sum(AXv.reshape((-1,X.shape[1],A.nz_per_row))
def sparse_dense_mv(A,x):
Axv = A.values[:]*x[A.ix_col];
return np.sum(Axv.reshape((-1,A.nz_per_row))
Whenever we add a convolutional map, or another image transformation, we get a full multiple of the input image size added to the hidden variables. That quickly becomes very large.
Would like the possibility to downsample after applying the map, so that more features can be included without blowing up the size of the hidden space too much.
To make reproducibility a thing, we need to couple output with how it was generated. Since the software is a moving target, we both need the commit ID and the command line used to run the code.
The command line is just sys.argv; the git commit we need to read from .git (possibly on pip install -e, stored as a variable).
So far the data was not normalized... is that the reason the predictions are not that good?
Traceback (most recent call last):
File "run.py", line 66, in <module>
steps=1, step_length=2)
File "/home/niklas/repos/toto/torsk/__init__.py", line 243, in train_predict_esn
inputs, labels, pred_labels = dataset[idx]
File "/home/niklas/repos/toto/torsk/data/torch_dataset.py", line 45, in __getitem__
images = self._images[
AttributeError: 'TorchImageDataset' object has no attribute '_images'
If an underlying periodicity is known a priori in the input data (as in many Earth-science datasets with a yearly cycle), it should be possible to specify the period length and ask us to automatically remove the average cycle before training.
This could either be done:
In the ocean data, the annual cycle is very clear in the cosine-transformed coefficients (less so in the pixel values).
In cases where the annual cycle is very dominant, this means that the NN doesn't need to spend its efforts reproducing it, possibly leading to missing the more subtle details that we're after.
Similarly, the (linear or quadratic) trend can be factored out of the data.
Needed feature: Predict a shorter distance into the future, then retrain (or feed truth) to increment time, then predict again, etc.
to reduce arguments
This indicates a bug in the input mapping.
To reproduce: set weights to zero, and replace
x, y = np.sin(t), np.cos(0.25 * t)
by
x, y = np.sin(0.25 * t), np.cos(t)
in cirle/run.py
libavfile complains about receiving fewer bytes than it asks for.
Tutorial that might be useful: here
Basically this has to be done:
To use script mode, be sure to inherit from the the torch.jit.ScriptModule base class (instead of torch.nn.Module) and add a torch.jit.script decorator to your Python function or a torch.jit.script_method decorator to your module’s methods.
is there a difference between pytorch and scipy pseudo inverse
Check how ESN performance depends on condition number/rank of reservoir.
Compare that to performance of reservoirs that are created from the identity matrix/diagonal matrix with appropriate eigenvalues to which a random unitary transformation is applied.
Associated problem: Detect when prediction quality begins to suck (complication: don't confuse with anomaly).
Due to the large dimensionality along the t-axis, make G_t banded (possibly even tridiagonal), corresponding to limiting the "smearing" along the t-axis to nearby times.
Tridiagonal: correlates only one step ahead and one back. Probably we want a few more steps.
TODO:
imed.py
(turn imed_loss
back on in test_run_kuro.py
and test_run_mackey_2d.py
params.backen = 'bohrium'
Write moving circle input dataset
Matplotlib is horrifically slow, and interpolates the data whether we want it or not. Would like to just write the actual pixels to video.
compare 3d IMED to the euclidean difference of blurred volumes
what to call it?
make it installable without torch
optionally:
pip install torsk[torch]
Allow user to choose between stable (but slow) SVD-based pseudoinverse, which guarantees a maximal condition number, and the faster simple least-squares solver.
preprocess data with non-uniform FT
dtype can be changed with the new backend features that will be introduced with #26.
this does not work properly for pytorch at the moment.
There are several different ways how to make use of the spatial correlations in the SSH input images:
For netter usability and analysis of time spent
Within every hpopt step, iterate over a number of tikhonov betas to find the best one. this will get rid of an optimization parameter.
Implement hyper paramter folder structure.
It might be feasible to precompute a lot of reservoirs with the following parameters:
* hdim: 5k, 10k, 15k, 20k
* precompute the spectral radius to scale later
* density: 1%
* input weight init
This should reduce the amortized run-time by a factor proportional to L_train.
Have a look at the first frame of the world data. The registered shape is transposed, which mangles the image. Needs to be SSH(ntime,nlat,nlon), but is SSH(ntime,nlon,nlat). @nmheim, can you fix this?
Generic image/scalar dataset classes
class ImageDataset:
def __init__(self, ...)
def to_img(self)
def to_feature(self, kwargs)
# can specify: raw pixels, different convs, sct/dct (with weighted coefficients?!)
Both for DCT / real predicitions there seems to be an initially bad prediction that surprisingly becomes better over time?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.