#StackBounty: #javascript #tensorflow #if-statement #optimization #tensor Saving previous values of a Tensorflow.js tensor

Bounty: 100

I have an function which stores all of the values of the tensor and then concatonates it into one matrix. The function looks like this:

    if (i == 1) {
        var y_pred1 = y_pred
    } else if (i == 2) {
        var y_pred2 = y_pred
    } else if (i == 3) {
        var y_pred3 = y_pred
    } else if (i == 4) {
        var y_pred4 = y_pred
tf.concat([y_pred1, y_pred2, y_pred3, y_pred4])

This function stores every value of y_pred across every iteration of for a loop. Is there a way to make this more efficient so that I do not need to have an obscure amount of if statements inside of the model. For your information y_pred is a tensor.

FYI: i stands for the iteration number so if iteration 1 is reached y_pred1 = y_pred

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.