1 Answer
1

My workaround would be to use tf.assign which would act like a lazy initializer, the shape would be before infered from d with tf.zeros_like. To get idea how does it work I made b a resource variable so it maintains state between sess.run calls.

your solution assigns b equal to d on each iteration which is not the behavior intended.
– MiloMinderbinderMar 15 at 7:05

I've edited the code to illustrate how you should use it. Split the assign and get_variable and use assign only before the loop. I've added add_one op that adds one to b and assigns it the value of addition to illustrate that it works. Moreover, I had to use resource variable so it maintains state between sess.run calls. Hope it clarifies things.
– MPękalskiMar 15 at 8:11