web-traffic-forecasting icon indicating copy to clipboard operation
web-traffic-forecasting copied to clipboard

Always uses initial_input for loop_fn

Open blablahaha opened this issue 4 years ago • 4 comments

Hi,

Thanks so much for sharing your perfect work. But I was confused in the decode part:

https://github.com/sjvasquez/web-traffic-forecasting/blob/6cb4a91da94b85857ed637afb53a8d9594f7623c/cnn.py#L342-L349

In line 343, function loop_fn, always takes initial_input as the parameter current_input.

I wonder why we don't use previous prediction for loop_fn? Just likes:

def body(time, elements_finished, emit_ta, *state_queues):
    current_input = tf.cond(time == 0, initial_input, emit_ta.read(time - 1)
    (next_finished, emit_output, state_queues) = loop_fn(time, current_input, state_queues)
    ...

blablahaha avatar Jul 29 '19 08:07 blablahaha

@SmileYuhao I've got the same doubt. Have you tried other implementation (e.g., using previous prediction in loop_fn)?

zxlmufc avatar Nov 13 '19 04:11 zxlmufc

@zxlmufc Yes, I tried another implementation, likes:

def _body(_current_time, _out_ta, *_state_queues):
    current_input = _out_ta.read(_current_time)
    next_input, updated_queues = _loop_fn(_current_time, current_input, _state_queues)
    _out_ta = _out_ta.write(_current_time + 1, next_input)

    return [_current_time + 1, _out_ta] + list(_state_queues)

But I didn't compare those two implementations. 🤣

blablahaha avatar Nov 13 '19 06:11 blablahaha

@SmileYuhao I've compared both implementation on synthetic dataset. They are having similar performance. The new one, using previous predict, performed slightly better. In case you are curious.

zxlmufc avatar Nov 14 '19 13:11 zxlmufc

@zxlmufc Coooool, thanks so much for satisfying my curiosity!

blablahaha avatar Nov 14 '19 14:11 blablahaha