nModes = 32 nTS = 1 smooth = 0 learning_range = CTimeRange.new( "1980-1-1", "2005-12-30" ) prediction_lag = CDuration.months(1) nInterationsPerProc = 10 batchSize = 100 nEpocs = 200 validation_fraction = 0.15 hiddenLayers = [100] activation = "relu" plotPrediction = True variables = [ Variable("ts"), Variable( "zg", 50000 ) ] project = Project(outDir,projectName) pcDataset = ClimateleDataset([Experiment(project, start_year, end_year, nModes, variable) for variable in variables], nts = nTS, smooth = smooth, timeRange = learning_range) td = IITMDataSource( "AI", "monthly" ) trainingDataset = TrainingDataset.new( [td], pcDataset, prediction_lag, decycle=True ) #ref_time_range = ( "1980-1-1", "2014-12-1" ) #ref_ts = ProjectDataSource( "HadISST_1.cvdp_data.1980-2017", [ "nino34" ], ref_time_range ) def learning_model_factory( weights = None ): return LearningModel( pcDataset, trainingDataset, batch=batchSize, epocs=nEpocs, vf=validation_fraction, hidden=hiddenLayers, activation=activation, weights=weights ) result = LearningModel.parallel_execute( learning_model_factory, nInterationsPerProc ) print "Got Best result, valuation loss = " + str( result.val_loss ) + " training loss = " + str( result.train_loss ) if plotPrediction:
pname = "20CRv2c" projectName = pname + "_EOFs" nModes = 10 start_year = 1851 end_year = 2012 nTS = 1 smooth = 0 freq = "Y" # Yearly input/outputs filter = "ja" # Filter months out of each year. learning_range = CTimeRange.new("1851-1-1", "2005-12-1") variables = [ Variable("ts"), Variable("zg", 80000) ] # [ Variable("ts"), Variable( "zg", 80000 ), Variable( "zg", 50000 ), Variable( "zg", 25000 ) ] project = Project.new(outDir, projectName) pcDataset = ClimateleDataset(projectName, [ Experiment(project, start_year, end_year, 64, variable) for variable in variables ], nts=nTS, smooth=smooth, filter=filter, nmodes=nModes, freq=freq, timeRange=learning_range) inputDataset = InputDataset([pcDataset]) prediction_lag = CDuration.years(1) nInterationsPerProc = 25 batchSize = 200