options_ref['--data_timescheme'] = 'rk2' options_ref['--channel_names'] = 'u' options_ref = conf.setoptions(argv=None, kw=options_ref, configfile=configfile) if torch.cuda.is_available(): options_ref['--device'] = 'cuda' else: options_ref['--device'] = 'cpu' globalnames_ref, callback_ref, model_ref, data_model_ref, sampling_ref, addnoise_ref = setenv.setenv( options_ref) globals().update(globalnames_ref) # initialization of parameters initparameters.initkernels(model_ref) initparameters.initexpr(model_ref, viscosity=viscosity, pattern=dataname) # model_ref.polys[k].coeffs(iprint=1) for poly in model_ref.polys: poly.coeffs(iprint=1) #%% options_1 = {} options_1['--name'] = 'heat-frozen-upwind-sparse0.005-noise0.001' configfile_1 = 'checkpoint/' + options_1['--name'] + '/options.yaml' options_1 = conf.setoptions(argv=None, kw=None, configfile=configfile_1, isload=True) if torch.cuda.is_available(): options_1['--device'] = 'cuda'
print(options) globalnames, callback, model, data_model, sampling, addnoise = setenv.setenv( options) globals().update(globalnames) torch.cuda.manual_seed_all(torchseed) torch.manual_seed(torchseed) np.random.seed(npseed) # initialization of parameters if start_from < 0: initparameters.initkernels(model, scheme=scheme) # initparameters.renormalize(model, u0) initparameters.initexpr(model, viscosity=viscosity, pattern='random') else: # load checkpoint of layer-$start_from callback.load(start_from, iternum='final') #%% train for block in blocks: if block <= start_from: continue print('block: ', block) print('name: ', name) r = np.random.randn() + torch.randn(1, dtype=torch.float64, device=device).item() with callback.open() as output: print('device: ', device, file=output) print('generate a random number to check random seed: ', r,