Disable Tensorflow debugging information

You can disable all debugging logs using os.environ : import os os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘3’ import tensorflow as tf Tested on tf 0.12 and 1.0 In details, 0 = all messages are logged (default behavior) 1 = INFO messages are not printed 2 = INFO and WARNING messages are not printed 3 = INFO, WARNING, and … Read more

How to prevent tensorflow from allocating the totality of a GPU memory?

You can set the fraction of GPU memory to be allocated when you construct a tf.Session by passing a tf.GPUOptions as part of the optional config argument: # Assume that you have 12GB of GPU memory and want to allocate ~4GB: gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) The per_process_gpu_memory_fraction acts as a hard upper bound … Read more

How to find which version of TensorFlow is installed in my system?

This depends on how you installed TensorFlow. I am going to use the same headings used by TensorFlow’s installation instructions to structure this answer. Pip installation Run: python -c ‘import tensorflow as tf; print(tf.__version__)’ # for Python 2 python3 -c ‘import tensorflow as tf; print(tf.__version__)’ # for Python 3 Note that python is symlinked to … Read more

What is the meaning of the word logits in TensorFlow? [duplicate]

Logits is an overloaded term which can mean many different things: In Math, Logit is a function that maps probabilities ([0, 1]) to R ((-inf, inf)) Probability of 0.5 corresponds to a logit of 0. Negative logit correspond to probabilities less than 0.5, positive to > 0.5. In ML, it can be the vector of … Read more

What is the difference between ‘SAME’ and ‘VALID’ padding in tf.nn.max_pool of tensorflow?

If you like ascii art: “VALID” = without padding: inputs: 1 2 3 4 5 6 7 8 9 10 11 (12 13) |________________| dropped |_________________| “SAME” = with zero padding: pad| |pad inputs: 0 |1 2 3 4 5 6 7 8 9 10 11 12 13|0 0 |________________| |_________________| |________________| In this example: … Read more

How to tell if tensorflow is using gpu acceleration from inside python shell?

No, I don’t think “open CUDA library” is enough to tell, because different nodes of the graph may be on different devices. When using tensorflow2: print(“Num GPUs Available: “, len(tf.config.list_physical_devices(‘GPU’))) For tensorflow1, to find out which device is used, you can enable log device placement like this: sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) Check your console for this … Read more

What are logits? What is the difference between softmax and softmax_cross_entropy_with_logits?

The softmax+logits simply means that the function operates on the unscaled output of earlier layers and that the relative scale to understand the units is linear. It means, in particular, the sum of the inputs may not equal 1, that the values are not probabilities (you might have an input of 5). Internally, it first … Read more

How to save/restore a model after training?

I am improving my answer to add more details for saving and restoring models. In(and after) Tensorflow version 0.11: Save the model: import tensorflow as tf #Prepare to feed input, i.e. feed_dict and placeholders w1 = tf.placeholder(“float”, name=”w1″) w2 = tf.placeholder(“float”, name=”w2″) b1= tf.Variable(2.0,name=”bias”) feed_dict ={w1:4,w2:8} #Define a test operation that we will restore w3 … Read more

TensorFlow not found using pip

I found this to finally work. python3 -m pip install –upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl Edit 1: This was tested on Windows (8, 8.1, 10), Mac and Linux. Change python3 to python according to your configuration. Change py3 to py2 in the url if you are using Python 2.x. Edit 2: A list of different versions if someone … Read more

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

What is this warning about? Modern CPUs provide a lot of low-level instructions, besides the usual arithmetic and logic, known as extensions, e.g. SSE2, SSE4, AVX, etc. From the Wikipedia: Advanced Vector Extensions (AVX) are extensions to the x86 instruction set architecture for microprocessors from Intel and AMD proposed by Intel in March 2008 and … Read more