在预测时,我得到的矢量是val_steps长度的两倍......预测被复制:1到val_steps的元素与从valsteps + 1到结尾的元素相同。我使用以下参数:
lookback <- 1 #look at X days past
step <- 1 # sample every X days
delay <- 1 # Forecast horizon
batch_size <- 1
myfc <- predict_generator(model, val_gengp,val_steps, verbose=T)
你知道为什么预测会重复吗? 可能我不太了解我正在使用的发电机:
generatorgp <- function(data, lookback, delay, min_index, max_index,
shuffle = FALSE, batch_size = batch_size, step = step) { #6
if (is.null(max_index)) max_index <- nrow(data) - delay - 1
i <- min_index + lookback
function() {
if (shuffle) {
rows <- sample(c((min_index+lookback):max_index), size = batch_size)
} else {
if (i + batch_size >= max_index)
i <<- min_index + lookback # i <<- 1 + lookback
rows <- c(i:min(i+batch_size, max_index)) # rows <- c(i:min(i+batch_size, maxtrain))
i <<- i + length(rows)
}
samples <- array(0, dim = c(length(rows),
lookback / step,
dim(data)[[-1]])) #View(samples)
targets <- array(0, dim = c(length(rows))) #targets
for (j in 1:length(rows)) {
indices <- seq(rows[[j]] - lookback, rows[[j]],
length.out = dim(samples)[[2]])
samples[j,,] <- data[indices,]
targets[[j]] <- data[rows[[j]] + delay,myy] #
}
list(samples)#, targets)
#samples
}
}
val_gengp = generatorgp(
data,
lookback = lookback,
delay = delay,
min_index = minval,
max_index = maxval,
step = step,
batch_size = batch_size
)
还想知道实际预测的第一个元素的索引是什么?第一个目标prediction be: data[(min_validation_set+lookback+1)]
?非常感谢