deepmind-research icon indicating copy to clipboard operation
deepmind-research copied to clipboard

issue with Transporter

Open Abdelrahman-Alkhodary opened this issue 4 years ago • 2 comments

Hello I'm trying to use transporter in my project, I made few changed for the function conflicting with tensorflow 2.0 now i'm trying to train my custom dataset, by this code

for idx, image_a_batch in enumerate(dataset_a): for idx, image_b_batch in enumerate(dataset_b): with tf.GradientTape() as tape: transporter_results = model(image_a_batch, image_b_batch, is_training=True) reconstructed_image_b = transporter_results['reconstructed_image_b'] loss = reconstruction_loss(image_b_batch, reconstructed_image_b) params = model.trainable_variables grads = tape.gradient(loss, params) opt.apply(grads, params)

Until the loss function everything is working fine, but when trying to get the trainable_variables from the model I got this error

ValueError: Transporter( encoder=Encoder(), keypointer=KeyPointer( num_keypoints=10, gauss_std=0.1, keypoint_encoder=Encoder(name='keypoint_encoder'), ), decoder=Decoder(initial_filters=4, output_size=[128, 128]), ) does not currently contain any trainable_variables.

Most Sonnet modules create variables the first time they are called with an input and requesting variables before this typically indicates a coding error.

You should refactor your code such that you request module variables after you pass an example input to the module. For example:

module = Transporter(
encoder=Encoder(),
keypointer=KeyPointer(
               num_keypoints=10,
               gauss_std=0.1,
               keypoint_encoder=Encoder(name='keypoint_encoder'),
           ),
decoder=Decoder(initial_filters=4, output_size=[128, 128]),

) output = module(input) params = module.trainable_variables

tensorflow version is 2.2.0 sonnet is 2.0

Abdelrahman-Alkhodary avatar Nov 15 '20 12:11 Abdelrahman-Alkhodary

You need tensorflow 1.13.1, as it states in requirements.txt I think the only compatible Python versions are 3.6 & 3.7

edxward avatar Mar 15 '21 10:03 edxward

You can download from these links Python3.6: https://www.python.org/downloads/release/python-360/ Python3.7: https://www.python.org/downloads/release/python-370/

edxward avatar Mar 15 '21 11:03 edxward