Home > database >  Why can the output of RNN layers, which is just the prediction of the next time step, represent the
Why can the output of RNN layers, which is just the prediction of the next time step, represent the

Time:11-14

Why can the output of RNN layers, which is just the prediction of the next time step, represent the features of the entire time series?

It makes no sense to me.

I need some help, please.

CodePudding user response:

it is for LSTM has identical results when the convolution layer is not, you may read from some topics comparing CONV and LSTM but that is not always. Read my simple codes that present simple time series attaches.

Sample: By using Kernel, the result of in series each of the numbers of expected outputs still has a similar plus or minus sign position in the result matrixes, notice not proved.

import tensorflow as tf

class MyLSTMLayer( tf.keras.layers.LSTM ):
    def __init__(self, units, return_sequences, return_state):
        super(MyLSTMLayer, self).__init__( units, return_sequences=True, return_state=False )
        self.num_units = units

    def build(self, input_shape):
        self.kernel = self.add_weight("kernel",
        shape=[int(input_shape[-1]),
        self.num_units])

    def call(self, inputs):
        return tf.matmul(inputs, self.kernel)

start = 3
limit = 33
delta = 3
sample = tf.range(start, limit, delta)
sample = tf.cast( sample, dtype=tf.float32 )
sample = tf.constant( sample, shape=( 10, 1, 1 ) )
layer = MyLSTMLayer(10, True, False)

print( layer(sample) )

Output: To prove is a bit of work, you do Eigen values and vectors depending on the level of expectation and question that required different potential of works.

 ...
 [[  3.0127144  -12.059593    -0.9939194  -11.179417     9.434317
   -17.499878    -5.380308     6.832542   -11.653082    -4.098554  ]]

 [[  3.3893037  -13.567043    -1.1181593  -12.576844    10.6136055
   -19.687363    -6.052847     7.6866097  -13.109716    -4.610873  ]]

 [[  3.765893   -15.074492    -1.2423992  -13.974272    11.792895
   -21.874847    -6.725385     8.540677   -14.566352    -5.123193  ]]], shape=(10, 1, 10), dtype=float32)
  • Related