WestCoastProjects
WestCoastProjects

Reputation: 63249

AttributeError: module 'tensorflow.compat.v2' has no attribute 'logging'

I have updated to the latest tensorflow via pip3:

pip3 install tensorflow

The following code is generating the error in the question title

tf.logging.info('embedding_name: %s', FLAGS.embedding_dimension)

AttributeError: module 'tensorflow.compat.v2' has no attribute 'logging'

Is this an out-of-date way to invoke the logging? Is there an alternative?

Upvotes: 1

Views: 4064

Answers (1)

Srihari Humbarwadi
Srihari Humbarwadi

Reputation: 2642

tf.logging.info('embedding_name: %s', FLAGS.embedding_dimension) is indeed an out-dated way of doing this. It is no longer supported. You can use tf.get_logger as an alternative. Here is an working example.

import tensorflow as tf
import logging

logger = tf.get_logger()
logger.setLevel(logging.INFO)

logger.info(' Hello World from TF')

outputs:

INFO:tensorflow: Hello World from TF

Upvotes: 3

Related Questions