samer@0: package samer.models; samer@0: import samer.tools.*; samer@0: import samer.core.*; samer@0: import samer.maths.*; samer@0: samer@0: samer@0: public class ICABundle extends AnonymousTask samer@0: { samer@0: public ICA ica; samer@0: public DiffScaler scaler; samer@0: public GeneralisedExponential genexp; samer@0: public BatchedTrainer tscaler, tica, tgenexp; samer@0: samer@0: public ICABundle(Vec x) { samer@0: ica=new ICA(x); samer@0: scaler=new DiffScaler(ica.output()); samer@0: genexp=new GeneralisedExponential(scaler.output()); samer@0: samer@0: ica.setOutputModel(scaler); samer@0: scaler.setOutputModel(genexp); samer@0: samer@0: tscaler=new BatchedTrainer(scaler.getScaleTrainer(),4); samer@0: tgenexp=new BatchedTrainer(genexp.getTrainer(),256); samer@0: tica =new BatchedTrainer(ica.getTrainer(),x.size()); samer@0: } samer@0: samer@0: public void setFlushTask(Task t) { tica.setFlushTask(t); } samer@0: samer@0: public Task getSyncTask() { samer@0: return new AnonymousTask() { samer@0: ICAScalerSync sync=new ICAScalerSync(ica,scaler); samer@0: public void run() { samer@0: sync.run(); samer@0: ica.execute("basis",Shell.env()); samer@0: } samer@0: }; samer@0: } samer@0: samer@0: public void run() throws Exception { samer@0: ica.infer(); samer@0: scaler.infer(); samer@0: genexp.compute(); samer@0: scaler.compute(); samer@0: tgenexp.run(); samer@0: tscaler.run(); samer@0: tica.run(); samer@0: } samer@0: samer@0: public void dispose() { samer@0: tica.dispose(); samer@0: tscaler.dispose(); samer@0: tgenexp.dispose(); samer@0: genexp.dispose(); samer@0: scaler.dispose(); samer@0: ica.dispose(); samer@0: } samer@0: }