def getModel(compile_ = True): modelpath = MODELPATH modelname = MODELNAME if not os.path.exists(modelpath): os.mkdir(modelpath) modelpath = os.path.join(modelpath,modelname) if not os.path.exists(modelpath): os.mkdir(modelpath) x_transform = [Normalize(0.0033127920560417023,0.012673124326485102)] y_transform = [cutOut([96,160,96,160])] train,test = getData(BATCH_SIZE, DIMENSION,CHANNELS, timeToPred=30, area_=cutOut([96,160,96,160]), y_transform=y_transform, x_transform=x_transform) model = ZeroInflated_negativ_Binomial((*DIMENSION,CHANNELS)) if compile_ == False: return model,modelpath,train,test def NLL(y_true, y_hat): return -y_hat.log_prob(y_true) model.compile(loss=NLL, optimizer=Adam( lr= 1e-3 )) model.summary() modelpath_h5 = os.path.join(modelpath, modelname+'-{epoch:03d}-{loss:03f}-{val_loss:03f}.h5') checkpoint = ModelCheckpoint(modelpath_h5, verbose=0, monitor='val_loss', save_best_only=True, mode='auto') return model,checkpoint,modelpath,train,test
def getModel(compile_=True): modelpath = MODELPATH modelname = MODELNAME if not os.path.exists(modelpath): os.mkdir(modelpath) modelpath = os.path.join(modelpath,modelname) if not os.path.exists(modelpath): os.mkdir(modelpath) #x_transform = [Normalize(0.0033127920560417023,0.012673124326485102)] #x_transform = [LogBin()] y_transform = [cutOut([16,80,16,80]),LogBin()] #y_transform = [cutOut([96,160,96,160]),LogBin()] train,test = getData(BATCH_SIZE, DIMENSION,CHANNELS, timeToPred=30, y_transform=y_transform) model = six_class_categorical((*DIMENSION,CHANNELS)) if compile_ == False: return model,modelpath,train,test neg_log_likelihood = lambda x, rv_x: tf.math.reduce_mean(-rv_x.log_prob(x)) def NLL(y_true, y_hat): return -y_hat.log_prob(y_true) model.compile(loss=NLL, optimizer=Adam( lr= 1e-4 )) model.summary() modelpath_h5 = os.path.join(modelpath, modelname+'-{epoch:03d}-{loss:03f}-{val_loss:03f}.h5') checkpoint = ModelCheckpoint(modelpath_h5, verbose=0, monitor='val_loss', save_best_only=True, mode='auto') return model,checkpoint,modelpath,train,test
def getModel(): modelpath = MODELPATH modelname = MODELNAME if not os.path.exists(modelpath): os.mkdir(modelpath) modelpath = os.path.join(modelpath,modelname) if not os.path.exists(modelpath): os.mkdir(modelpath) input_shape = (*DIMENSION,CHANNELS) model = ZeroInflated_negativ_Binomial( input_shape=input_shape ) y_transform = [cutOut([7,57,7,57])] train,test = getData(BATCH_SIZE, DIMENSION,CHANNELS, timeToPred=10, y_transform=y_transform) def NLL(y_true, y_hat): return -y_hat.log_prob(y_true) #neg_log_likelihood = lambda x, rv_x: tf.math.reduce_mean(-rv_x.log_prob(x)) model.compile(loss=NLL, optimizer=Adam( lr= 1e-2 )) model.summary() modelpath_h5 = os.path.join(modelpath, modelname+'-{epoch:03d}-{loss:03f}-{val_loss:03f}.h5') checkpoint = ModelCheckpoint(modelpath_h5, verbose=0, monitor='val_loss', save_best_only=True, mode='auto') return model,checkpoint,modelpath,train,test
def getModel(compile_ = True): modelpath = MODELPATH modelname = MODELNAME if not os.path.exists(modelpath): os.mkdir(modelpath) modelpath = os.path.join(modelpath,modelname) if not os.path.exists(modelpath): os.mkdir(modelpath) y_transform = [cutOut([16,80,16,80])] train,test = getData(BATCH_SIZE, DIMENSION,CHANNELS, timeToPred=30, keep_sequences = True, y_transform=y_transform) input_shape = (*DIMENSION,CHANNELS) model = ZeroInflated_Poisson(input_shape=input_shape) if compile_ == False: return model,modelpath,train,test neg_log_likelihood = lambda x, rv_x: tf.math.reduce_mean(-rv_x.log_prob(x)) model.compile(loss=neg_log_likelihood, optimizer=Adam( lr= 1e-4 )) model.summary() modelpath_h5 = os.path.join(modelpath, modelname+'-{epoch:03d}-{loss:03f}-{val_loss:03f}.h5') checkpoint = ModelCheckpoint(modelpath_h5, verbose=0, monitor='val_loss', save_best_only=True, mode='auto') return model,checkpoint,modelpath,train,test
DIMENSION = (96,96) CHANNELS = 5 MODELPATH = "./Models_weights" MODELNAME = "30min_LSTM_zPoisson" modelpath = MODELPATH modelname = MODELNAME if not os.path.exists(modelpath): os.mkdir(modelpath) modelpath = os.path.join(modelpath,modelname) if not os.path.exists(modelpath): os.mkdir(modelpath) y_transform = [cutOut([16,80,16,80])] #x_transform = [Normalize(0.007742631458799244, 0.015872015890555563 )] train,test = getData(BATCH_SIZE, DIMENSION,CHANNELS, timeToPred=30, keep_sequences = True, y_transform=y_transform) neg_log_likelihood = lambda x, rv_x: tf.math.reduce_mean(-rv_x.log_prob(x)) model = CNN_LSTM_Poisson((*DIMENSION,CHANNELS)) model.compile(loss=neg_log_likelihood, optimizer=Adam( lr= 1e-4 )) model.summary()