Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add weather data #4

Open
xiang526 opened this issue Mar 30, 2021 · 0 comments
Open

add weather data #4

xiang526 opened this issue Mar 30, 2021 · 0 comments

Comments

@xiang526
Copy link

Hi, Professor, when i read your paper, i have an idea that is to add weather(eg precipitation) into the model, then I have done something to the DeepJMQR model as following:

weather data processing

weather_feats = weather['precipitation'].values[:,np.newaxis]

---------------- Build lags

weather_feats[:-NUM_LAGS,:] = weather_feats[NUM_LAGS:,:]
weather_feats_train = weather_feats[:i_train,:]
weather_feats_val = weather_feats[i_train:i_val,:]
weather_feats_test = weather_feats[i_val:i_test,:]
#深度学习模型for mean

---------------- Independent deep learning models for mean and quantiles

def tilted_loss(q,y,f):
e = (y-f)
# The term inside k.mean is a one line simplification of the first equation
return K.mean(q*e + K.clip(-e, K.epsilon(), np.inf), axis=-1)

def build_model(loss="mse", num_outputs=1):
model = Sequential()

model.add(ConvLSTM2D(filters=100, kernel_size=(3, 3),
               input_shape=(None, nx, ny, 1),
               padding='same', return_sequences=False))
model.add(BatchNormalization())
model.add(Dropout(0.75))

model.add(Dense(units=num_outputs, 
                kernel_regularizer=regularizers.l2(0.0001),
         ))
model.add(Activation("linear"))

model.compile(loss=loss, optimizer='nadam')

return model

print ("\nTraining NN for mean...")

checkpoint best model

checkpoint = ModelCheckpoint("weights_mean.best.hdf5", monitor='val_loss', verbose=1, save_best_only=True, mode='min')

fit model to the mean

model_mean = build_model(loss="mse", num_outputs=1)
model_mean.summary()
model_mean.fit(
[X_train[:,:,:,:,np.newaxis],weather_feats_train[:,:]],
y_train[:,:,:,np.newaxis],
batch_size=128,
epochs=N_EPOCHS, #100
validation_data=([X_val[:,:,:,:,np.newaxis],weather_feats_val[:,:]],y_val[:,:,:,np.newaxis]),
callbacks=[checkpoint],
verbose=0)

But there is a error:ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays

I have tried to solve this problem, but failed. Could you give me a good idea?
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant