How can I reuse this tensorflow layer ?

The name of the picture


How can I reuse this tensorflow layer ?



I'm writing a model in Tensorflow that I was used to use with PyTorch. Some mechanisms being very much different, I'm stuck at some points.
In particular:


dense = tf.layers.dense
adam = tf.train.AdamOptimizer
nb_joints= 3
code_size = 8

joints_info = tf.placeholder(tf.float32, shape = [None,nb_joints], name = 'joints_state')
target_info = tf.placeholder(tf.float32, shape = [None,2], name = 'target_pos')

next_joint_info = tf.placeholder(tf.float32, shape = [None,nb_joints], name = 'next_joints_state')

with tf.variable_scope('Encoder'):

e1 = dense(joints_info, 32, activation = tf.nn.relu, name ='encoding_1')
code = dense(e1, code_size, activation = tf.nn.relu, name ='code')

d1 = dense(code, code_size, activation = tf.nn.relu, name ='decoding_1')
recon = dense(d1, code_size, activation = tf.nn.relu, name ='reconstructed')

with tf.variable_scope('EncoderLoss'):

encoder_loss = tf.squared_difference(joints_info, recon)
train_encoder = adam(3e-4).minimize(encoder_loss)

with tf.variable_scope('Task'):

t1 = dense(code, 32, activation = tf.nn.relu, name ='task_code')

t1_targ = dense(target_info, 32, activation = tf.nn.relu, name ='task_target')

task_joint = tf.concat([t1,t1_targ],1, name ='States_concatenation')

t2 = dense(task_joint, 128, activation = tf.nn.relu, name = 'task_joint_transformation')

task_prediction = dense(t2, code_size, activation = None, name = 'task_prediction')

with tf.variable_scope('TaskLoss'):

task_real = here, I want to call the CODE operation from the encoder but using next_joint_info placeholder
task_loss = tf.squared_difference(task_prediction, task_real)



Could someone point me in the right direction ? I have no idea on how to proceed here.



Thanks a lot !





What is the error? What was the code with PyTorch? We cannot really help here.
– lmontigny
3 hours ago





Well, in the TaskLoss variable scope, I need to reuse the Encoder module to create the task_real code. But I can't figure out how. In Pytorch, I would have simply used my module and wrote something like encoder_module(next_joints_info). Sorry if it was unclear.
– Mehd
3 hours ago




TaskLoss


Encoder









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP