Recurrent Neural Networks

6 / 17

Recurrent Neural Networks - Forecasting a Time Series







Please login to comment

11 Comments

# This function creates as many time series as requested (via the batch_size argument),
# each of length n_steps, and there is just one value per time step in each series
# (i.e., all series are univariate)
def generate_time_series(batch_size, n_steps):
    freq1, freq2, offsets1, offsets2 = np.random.rand(4, batch_size, 1)
    # The linspace() function returns evenly spaced numbers over a specified interval
    time = np.linspace(0, 1, n_steps)
    series = 0.5 * np.sin((time - offsets1) * (freq1 * 10 + 10))  #   wave 1
    series += 0.2 * np.sin((time - offsets2) * (freq2 * 20 + 20)) # + wave 2
    series += 0.1 * (np.random.rand(batch_size, n_steps) - 0.5)   # + noise

    # The function returns a NumPy array of shape [batch size, time steps, 1],
    # where each series is the sum of two sine waves of fixed amplitudes but
    # random frequencies and phases, plus a bit of noise
    return series[..., np.newaxis].astype(np.float32)

Please make me understand this function

  Upvote    Share

i understood

  Upvote    Share

my lab account has only two directories one that I created and the other is cloudxlab_jupyter_notebooks

  Upvote    Share

I dont see the notebok file used in the video in my lab account

  Upvote    Share

Hi, I didn't understand why the last layer is not ideal. Can you please ellaborate? slide 59. 

  Upvote    Share

Hi,

The last layer is not ideal as it must have a single unit because we want to forecast a univariate time series, and this means we must have a single output value per time step. However, having a single unit means that the hidden state is just a single number which is not much useful.

Also, since a SimpleRNN layer uses the tanh activation function by default, the predicted values must lie within the range –1 to 1. But what if you want to use another activation function? Hope this explains why it is not much useful.

Thanks.

  Upvote    Share

I understood the "activation function" reason. But can you please ellaorate on "hidden state is just a single number which is not much useful" ? Do you mean it won't be useful when we are dealing with multi-variate output?

  Upvote    Share

Hi,

Multi-variable itself means multiple numbers. So it will not be much useful having a single unit.

Thanks.

 1  Upvote    Share

I am finding some notebooks as empty on my jupyter lab.What to do?

  Upvote    Share

Hi,

This may be because you may have opened them but didn't code anything. The notebooks in which you coded in the guided projects will be on the cloudxlab_jupyter_notebooks folder.

Thanks.

  Upvote    Share