in Education by
I'm reading the 14th chapter of Hands-On Machine Learning with Scikit-Learn and TensorFlow. It says: Although using an OutputProjectionWrapper is the simplest solution to reduce the dimensionality of the RNN’s output sequences down to just one value per time step (per instance), it is not the most efficient. There is a trickier but more efficient solution: you can reshape the RNN outputs, then apply a single fully connected layer with the appropriate output size. [...] This can provide a significant speed boost since there is just one fully connected layer instead of one per time step. This makes no sense to me. In case of OutputProjectionWrapper we need to perform 2 operations per time step: Calculate new hidden state based on previous hidden state and input. Calculate output by applying dense layer to calculated hidden state. Of course, when we use plain BasicRNNCell + dense layer on top, we need to do only one operation on each time step (the first one), but then we need to pipe each output tensor through our dense layer. So we need to perform the very same amount of operations in the both cases. Also, I can't understand the following part: This can provide a significant speed boost since there is just one fully connected layer instead of one per time step. Don't we have only one fully connected layer in both cases? As far as I understand OutputProjectionWrapper uses the same shared layer on each time step. I don't even know how it can create different layer for every time step because OutputProjectionWrapper has no information about the amount of time steps we will be using. I will be very grateful if someone can explain the difference between these approaches. UPD Here is pseudocode for the question. Am I missing something? # 2 time steps, x1 and x2 - inputs, h1 and h2 - hidden states, y1 and y2 - outputs. # OutputProjectionWrapper h1 = calc_hidden(x1, 0) y1 = dense(h1) h2 = calc_hidden(x2, h1) y2 = dense(h2) # BasicRNNCell + dense layer on top of all time steps h1 = calc_hidden(x1, 0) y1 = h1 h2 = calc_hidden(x2, h1) y2 = h2 y1 = dense(y1) y2 = dense(y2) UPD 2 I've created two small code snippets (one with OutputProjectionWrapper and another with BasicRNNCell and tf.layers.dense on top) - both created 14 variables with the same shape. So there is definitely no memory differences between these approaches. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
My guess is applying 1 layer to a tensor of shape (x, n) is faster than applying same layer to a tensor of shape (x) n times due to matrix multiplication optmizations.

Related questions

0 votes
    Layer is like transparent sheet that can hold objects and are stacked on top of each other, it is useful ... elemants of your movies Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    How are input layer units connected to second layer in competitive learning networks? (a) feedforward manner (b) ... (d) feedforward or feedback Please answer the above question....
asked Aug 27, 2022 in Education by JackTerrance
0 votes
    In self organizing network, how is layer connected to output layer? (a) some are connected (b) all are one to one ... (d) none of the mentioned Please answer the above question....
asked Aug 27, 2022 in Education by JackTerrance
0 votes
    I need to create a hollow pyramid with a solid top layer like so: Height: 5 * *** * * * ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    Which layer handles top-level communication? (a) Network Access Layer (b) Internet Layer (c) Transport ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    In the layered design _____________ is the top most layer. 1. Components 2. Object 3. None of the options 4. Sub process 5. Process...
asked Aug 30, 2021 in Technology by JackTerrance
0 votes
    What is the method to overcome the Decay of Information through time in RNN known as? (a) Back Propagation (b) Gradient Descent (c) Activation (d) Gating...
asked Oct 20, 2020 in Technology by Editorial Staff
0 votes
    Sun also has the Hadoop Live CD ________ project, which allows running a fully functional Hadoop cluster using a live CD. 1. OpenOffice.org 2. OpenSolaris 3. GNU 4. Linux...
asked Dec 6, 2022 in Education by JackTerrance
0 votes
    I'm relatively new to C++, recently moved from C# and Java (and before that, used to work in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    On my website I am trying to program a feature, similar to facebook and twitters timeline, where a user ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 3, 2022 in Education by JackTerrance
0 votes
    On my website I am trying to program a feature, similar to facebook and twitters timeline, where a user ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    Which of these can be used to fully abstract a class from its implementation? (a) Objects (b) Packages (c) ... & Packages of Java Select the correct answer from above options...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    You may have seen ferns among the ornamental plants in a garden. Take a leaf of a fully grown fern and observe it carefully. Select the correct answer from above options...
asked Nov 9, 2021 in Education by JackTerrance
0 votes
    Buffer-overflow may remain as a bug in apps if __________ are not done fully. (a) boundary hacks (b) memory ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    Which of these can be used to fully abstract a class from its implementation? (a) Objects (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
...