brainpy / BrainPy

Brain Dynamics Programming in Python
https://brainpy.readthedocs.io/
GNU General Public License v3.0
514 stars 93 forks source link

Can not train reservoir network using multiple trials #686

Open YNCris opened 2 weeks ago

YNCris commented 2 weeks ago

Hello!

I have multiple trials and the shape is [1950,48](time, feature). I read the comments of function 'fit' and organize my data into a tensor [442,1950,48]. The XTrain and YTrain are the same shape. And I define the reservoir network using:

model = RCN(
    num_in=48,
    leaky_rate=0.1,
    in_connectivity=0.1,
    num_hidden=900, 
    rec_connectivity=0.1,
    num_out=48)

And I use the offline trainer:

dt = 0.1
trainer = bp.OfflineTrainer(model, \
                            fit_method=bp.algorithms.RidgeRegression(1e-7), \
                                dt=dt)

_ = trainer.fit([bm.asarray(XTrain),
                  bm.asarray(YTrain)])

It shows the error: Scanned function carry input and carry output must have equal types (e.g. shapes and dtypes of arrays), but they differ:

Revise the scanned function so that all output types (e.g. shapes and dtypes) match the corresponding input types.

But when I only use 1 data [1,1950,48] to train the model, it works. How can I train the network using multiple trials?

Routhleck commented 1 week ago

@ztqakita