简体   繁体   中英

How can I weight inputs for Keras model on tensorflow?

I want to predict a time series value (regression task). But I need to tell the machine that recent observations in a batch relate stronger to the label than older ones.

In other words - I want to weight input values. How can this be done?

You can use autocorrelation of Y with itself using a time lag, like:

time_lag=4
x_train=dataframe[0:-timelag]
y_train=dataframe[time_lag:]

from pandas.plotting import autocorrelation_plot

autocorrelation_plot(dataframe)

You will notice autocorrelation will decrease its value with more distant values.

However, a proper neural network will learn that without being explicitly programmed, given that correlation with close values will naturally be bigger, and so the weights, in absolute values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM