question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility with tensorflow 2.0

See original GitHub issue

wandb --version && python --version && uname

  • Weights and Biases version: 0.8.16
  • Python version: 3.7.4
  • Operating System: Win 10

Description

I try to log my custom losses using tensorboard. It seems wandb isn’t compatible with the @tf.function decorator, and it would mean that using wandb would slow down the code considerably. Is tf.function supported ?

What I Did

@tf.function
def train_on_batch(self, obs1, obs2, act, rew, done, step):
[...]
   wandb.tensorflow.log('losses/q1_loss', q1_loss, step=step)

Error: TypeError: To be compatible with tf.contrib.eager.defun, Python functions must return zero or more Tensors; in compilation of <function create_converted_entity_factory.<locals>.create_converted_entity.<locals>.tf__log.<locals>.<lambda> at 0x000001D386C6B288>, found return value of type <class ‘wandb.history.History’>, which is not a Tensor.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
raubitsjcommented, Dec 3, 2019

@Danmou, the branch should be fixed now, there was an issue how the “pip install …#egg=wandb” command was messing with the python environment.

Please try the: pip install --upgrade git+git://github.com/wandb/client.git@fix/tensorboard-import-issue#egg=wandb command again. you might want to pip uninstall wandb first just to make sure it grabs a new version.

0reactions
fellhorncommented, Jun 23, 2020

Still having the same issue with TF 2.1.1 and TensorBoard 2.1.1. I run

import tensorflow as tf
import wandb
wandb.init(sync_tensorboard=True)
writer = tf.summary.create_file_writer('logdir')

I had the same issue when using TF and TensorBoard from the global site packages. When I switched to a venv on the machine it worked though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TensorFlow version compatibility
TensorFlow 1.2 might support GraphDef versions 4 to 7. · TensorFlow 1.3 could add GraphDef version 8 and support versions 4 to 8....
Read more >
Install TensorFlow 2
Learn how to install TensorFlow on your system. Download a pip package, run in a Docker container, or build from source.
Read more >
Effective Tensorflow 2 | TensorFlow Core
This guide provides a list of best practices for writing code using TensorFlow 2 (TF2), it is written for users who have recently...
Read more >
Module: tf.compat | TensorFlow v2.11.0
The tf.compat module contains two sets of compatibility functions. Tensorflow 1.x and 2.x APIs. The compat.
Read more >
TensorFlow 1.x vs TensorFlow 2 - Behaviors and APIs
To be TF2 compatible, your code must be compatible with the full set of TF2 behaviors. During migration, you can enable or disable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found