Dataset Viewer
Auto-converted to Parquet Duplicate
instruction
stringlengths
1
910
input
stringclasses
1 value
output
stringlengths
19
40.6k
system
stringclasses
2 values
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
<h2>What is this warning about?</h2> <p>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 <a href="https://en.wikipedia.org/wiki/Advanced_Vector_Extensions" rel="noreferrer">Wikipedia</a>:</p> <blockquote> <p><strong>Adv...
you are the stackoverflow assistant
TensorFlow not found using pip
<p>I found this to finally work.</p> <pre><code>python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl </code></pre> <p>Edit 1: This was tested on Windows (8, 8.1, 10), Mac and Linux. Change <code>python3</code> to <code>python</code> according to your co...
you are the stackoverflow assistant
How to save/restore a model after training?
<p>In (and after) <strong>Tensorflow version 0.11</strong>:</p> <p><strong>Save the model:</strong></p> <pre><code>import tensorflow as tf #Prepare to feed input, i.e. feed_dict and placeholders w1 = tf.placeholder(&quot;float&quot;, name=&quot;w1&quot;) w2 = tf.placeholder(&quot;float&quot;, name=&quot;w2&quot;) b1= ...
you are the stackoverflow assistant
What are logits? What is the difference between softmax and softmax_cross_entropy_with_logits?
<p>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 <em>not</em> probabilities (you might have an input of 5). Internally...
you are the stackoverflow assistant
What is the meaning of the word logits in TensorFlow?
<p>Logits is an overloaded term which can mean many different things:</p> <hr> <p><strong>In Math</strong>, <a href="https://en.wikipedia.org/wiki/Logit" rel="noreferrer">Logit</a> is a function that maps probabilities (<code>[0, 1]</code>) to R (<code>(-inf, inf)</code>)</p> <p><a href="https://i.sstatic.net/zto5q....
you are the stackoverflow assistant
How to tell if tensorflow is using gpu acceleration from inside python shell?
<p>No, I don't think &quot;open CUDA library&quot; is enough to tell, because different nodes of the graph may be on different devices.</p> <p>When using tensorflow2:</p> <pre><code>print(&quot;Num GPUs Available: &quot;, len(tf.config.list_physical_devices('GPU'))) </code></pre> <p>For tensorflow1, to find out which d...
you are the stackoverflow assistant
What is the difference between &#39;SAME&#39; and &#39;VALID&#39; padding in tf.nn.max_pool of tensorflow?
<p>If you like ascii art:</p> <ul> <li><p><code>"VALID"</code> = without padding:</p> <pre><code> inputs: 1 2 3 4 5 6 7 8 9 10 11 (12 13) |________________| dropped |_________________| </code></pre></li> <li><p><code>"SAME"</code> = ...
you are the stackoverflow assistant
How to find which version of TensorFlow is installed in my system?
<p>This depends on how you installed TensorFlow. I am going to use the same headings used by <a href="https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#download-and-setup" rel="noreferrer">TensorFlow's installation instructions</a> to structure this answer.</p> <hr> <h2>Pip installation</h2> <p>Run...
you are the stackoverflow assistant
Could not find a version that satisfies the requirement tensorflow
<p>The latest requirements for running TensorFlow are documented in the <a href="https://www.tensorflow.org/install/pip" rel="noreferrer">installation documentation</a>.</p> <ul> <li><p>TensorFlow only supports 64-bit Python</p> </li> <li><p>TensorFlow only supports certain versions of Python (for example, Python 3.6 i...
you are the stackoverflow assistant
How to prevent tensorflow from allocating the totality of a GPU memory?
<p>You can set the fraction of GPU memory to be allocated when you construct a <a href="https://www.tensorflow.org/api_docs/python/tf/Session" rel="noreferrer"><code>tf.Session</code></a> by passing a <a href="https://github.com/tensorflow/tensorflow/blob/08ed32dbb9e8f67eec9efce3807b5bdb3933eb2f/tensorflow/core/protobu...
you are the stackoverflow assistant
Disable Tensorflow debugging information
<p>You can disable all debugging logs using <code>os.environ</code> :</p> <pre><code>import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf </code></pre> <p>Tested on tf 0.12 and 1.0</p> <p>In details, </p> <pre><code>0 = all messages are logged (default behavior) 1 = INFO messages are not prin...
you are the stackoverflow assistant
Convert a tensor to numpy array in Tensorflow?
<h1><strong>TensorFlow 2.x</strong></h1> <p><a href="https://www.tensorflow.org/guide/eager" rel="noreferrer">Eager Execution</a> is enabled by default, so just call <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/framework/ops.py#L1042-L1067" rel="noreferrer"><strong><code>.numpy()</cod...
you are the stackoverflow assistant
Which TensorFlow and CUDA version combinations are compatible?
<p><strong>TL;DR</strong>) See this table: <a href="https://www.tensorflow.org/install/source#gpu" rel="noreferrer">https://www.tensorflow.org/install/source#gpu</a></p> <h2>Generally:</h2> <p>Check the CUDA version:</p> <pre><code>cat /usr/local/cuda/version.txt </code></pre> <p>and cuDNN version:</p> <pre><code>grep ...
you are the stackoverflow assistant
How to compile Tensorflow with SSE4.2 and AVX instructions?
<p>I just ran into this same problem, it seems like Yaroslav Bulatov's suggestion doesn't cover SSE4.2 support, adding <code>--copt=-msse4.2</code> would suffice. In the end, I successfully built with</p> <pre><code>bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --confi...
you are the stackoverflow assistant
What&#39;s the difference between tf.placeholder and tf.Variable?
<p>In short, you use <code>tf.Variable</code> for trainable variables such as weights (W) and biases (B) for your model.</p> <pre><code>weights = tf.Variable( tf.truncated_normal([IMAGE_PIXELS, hidden1_units], stddev=1.0 / math.sqrt(float(IMAGE_PIXELS))), name='weights') biases = tf.Variable(t...
you are the stackoverflow assistant
How to print the value of a Tensor object in TensorFlow?
<p>The easiest<sup>[A]</sup> way to evaluate the actual value of a <code>Tensor</code> object is to pass it to the <code>Session.run()</code> method, or call <code>Tensor.eval()</code> when you have a default session (i.e. in a <code>with tf.Session():</code> block, or see below). In general<sup>[B]</sup>, you cannot p...
you are the stackoverflow assistant
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied:
<p>Just type the command you want execute with the user permission, if you don't want to change the permission:</p> <pre><code>pip3 install --upgrade tensorflow-gpu --user </code></pre>
you are the stackoverflow assistant
What&#39;s the difference of name scope and a variable scope in tensorflow?
<p>Let's begin by a short introduction to variable sharing. It is a mechanism in <code>TensorFlow</code> that allows for sharing variables accessed in different parts of the code without passing references to the variable around. </p> <p>The method <a href="https://www.tensorflow.org/api_docs/python/tf/get_variable" r...
you are the stackoverflow assistant
Ordering of batch normalization and dropout?
<p>In the <a href="https://arxiv.org/pdf/1502.03167.pdf" rel="noreferrer">Ioffe and Szegedy 2015</a>, the authors state that "we would like to ensure that for any parameter values, the network always produces activations with the desired distribution". So the Batch Normalization Layer is actually inserted right after a...
you are the stackoverflow assistant
How to get current available GPUs in tensorflow?
<p>There is an undocumented method called <a href="https://github.com/tensorflow/tensorflow/blob/d42facc3cc9611f0c9722c81551a7404a0bd3f6b/tensorflow/python/client/device_lib.py#L27" rel="noreferrer"><code>device_lib.list_local_devices()</code></a> that enables you to list the devices available in the local process. (<s...
you are the stackoverflow assistant
Tensorflow 2.0 - AttributeError: module &#39;tensorflow&#39; has no attribute &#39;Session&#39;
<p>According to <code>TF 1:1 Symbols Map</code>, in TF 2.0 you should use <code>tf.compat.v1.Session()</code> instead of <code>tf.Session()</code></p> <p><a href="https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0" rel="noreferrer">https://docs.google.com/spreadsheets/d/1FLF...
you are the stackoverflow assistant
Keras, How to get the output of each layer?
<p>You can easily get the outputs of any layer by using: <code>model.layers[index].output</code></p> <p>For all layers use this:</p> <pre><code>from keras import backend as K inp = model.input # input placeholder outputs = [layer.output for layer in model.layers] # ...
you are the stackoverflow assistant
In TensorFlow, what is the difference between Session.run() and Tensor.eval()?
<p>If you have a <code>Tensor</code> t, calling <a href="https://www.tensorflow.org/api_docs/python/tf/Tensor#eval" rel="noreferrer"><code>t.eval()</code></a> is equivalent to calling <code>tf.get_default_session().run(t)</code>.</p> <p>You can make a session the default as follows:</p> <pre><code>t = tf.constant(42....
you are the stackoverflow assistant
How can I run Tensorboard on a remote server?
<p>Here is what I do to avoid the issues of making the remote server accept your local external IP:</p> <ul> <li>when I ssh into the machine, I use the option <code>-L</code> to transfer the port <code>6006</code> of the remote server into the port <code>16006</code> of my machine (for instance): <code> ssh -L 16006:1...
you are the stackoverflow assistant
How to build and use Google TensorFlow C++ api
<p>To get started, you should download the source code from Github, by <a href="http://tensorflow.org/get_started/os_setup.md#installing_from_sources">following the instructions here</a> (you'll need <a href="http://bazel.io">Bazel</a> and a recent version of GCC).</p> <p>The C++ API (and the backend of the system) is...
you are the stackoverflow assistant
TypeError: Descriptors cannot not be created directly
<p>Sometimes the <a href="https://pypi.org/project/protobuf/" rel="noreferrer">protobuf</a> package might be installed without your involvement. For this, you have two solutions to apply. Try one of the below solutions and it should work.</p> <h2>Solution 1:</h2> <p>You can downgrade the <a href="https://pypi.org/proje...
you are the stackoverflow assistant
What is the difference between steps and epochs in TensorFlow?
<p>A training step is one gradient update. In one step <code>batch_size</code> examples are processed.</p> <p>An epoch consists of one full cycle through the training data. This is usually many steps. As an example, if you have 2,000 images and use a batch size of 10 an epoch consists of:</p> <pre><code>2,000 images / ...
you are the stackoverflow assistant
How to run Tensorflow on CPU
<p>You can also set the environment variable to </p> <pre><code>CUDA_VISIBLE_DEVICES="" </code></pre> <p>without having to modify the source code.</p>
you are the stackoverflow assistant
Why is TensorFlow 2 much slower than TensorFlow 1?
<p><strong>UPDATE 8/<s>17</s>30/2020</strong>: TF 2.3 has finally done it: all cases run as fast, or notably faster, than any previous version.</p> <p>Further, my previous update was unfair to TF; my GPU was to blame, has been overheating lately. If you see a rising stem plot of iteration times, it's a reliable symptom...
you are the stackoverflow assistant
What is the role of &quot;Flatten&quot; in Keras?
<p>If you read the Keras documentation entry for <a href="https://keras.io/layers/core/#dense" rel="noreferrer"><code>Dense</code></a>, you will see that this call:</p> <pre><code>Dense(16, input_shape=(5,3)) </code></pre> <p>would result in a <code>Dense</code> network with 3 inputs and 16 outputs which would be appli...
you are the stackoverflow assistant
TensorFlow, why was python the chosen language?
<p>The most important thing to realize about TensorFlow is that, for the most part, <em>the core is not written in Python</em>: It's written in a combination of highly-optimized C++ and CUDA (Nvidia's language for programming GPUs). Much of that happens, in turn, by using <a href="http://eigen.tuxfamily.org/index.php...
you are the stackoverflow assistant
What does tf.nn.embedding_lookup function do?
<p>Yes, this function is hard to understand, until you get the point.</p> <p>In its simplest form, it is similar to <code>tf.gather</code>. It returns the elements of <code>params</code> according to the indexes specified by <code>ids</code>.</p> <p>For example (assuming you are inside <code>tf.InteractiveSession()</...
you are the stackoverflow assistant
Understanding TensorBoard (weight) histograms
<p>It appears that the network hasn't learned anything in the layers one to three. The last layer does change, so that means that there either may be something wrong with the gradients (if you're tampering with them manually), you're constraining learning to the last layer by optimizing only its weights or the last lay...
you are the stackoverflow assistant
Can I run Keras model on gpu?
<p>Yes you can run keras models on GPU. Few things you will have to check first.</p> <ol> <li>your system has GPU (Nvidia. As AMD doesn't work yet)</li> <li>You have installed the GPU version of tensorflow</li> <li>You have installed CUDA <a href="https://www.tensorflow.org/install/install_linux" rel="noreferrer">insta...
you are the stackoverflow assistant
How does tf.app.run() work?
<pre><code>if __name__ == "__main__": </code></pre> <p>means current file is executed under a shell instead of imported as a module.</p> <pre><code>tf.app.run() </code></pre> <p>As you can see through the file <code>app.py</code></p> <pre><code>def run(main=None, argv=None): """Runs the program with an optional '...
you are the stackoverflow assistant
Tensorflow - ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type float)
<p><strong>TL;DR</strong> Several possible errors, most fixed with <code>x = np.asarray(x).astype('float32')</code>.</p> <p>Others may be faulty data preprocessing; ensure everything is <em>properly formatted</em> (categoricals, nans, strings, etc). Below shows what the model expects:</p> <pre class="lang-py prettyprin...
you are the stackoverflow assistant
Could not load dynamic library &#39;cudart64_101.dll&#39; on tensorflow CPU-only installation
<h1>Tensorflow 2.1+</h1> <h2>What's going on?</h2> <p>With the <a href="https://github.com/tensorflow/tensorflow/releases/tag/v2.1.0" rel="noreferrer">new Tensorflow 2.1 release</a>, the default <code>tensorflow</code> pip package contains both CPU and GPU versions of TF. In previous TF versions, not finding the CUDA l...
you are the stackoverflow assistant
Deep-Learning Nan loss reasons
<p>There are lots of things I have seen make a model diverge.</p> <ol> <li><p>Too high of a learning rate. You can often tell if this is the case if the loss begins to increase and then diverges to infinity.</p> </li> <li><p>I am not to familiar with the DNNClassifier but I am guessing it uses the categorical cross en...
you are the stackoverflow assistant
What does this tensorflow message mean? Any side effect? Was the installation successful?
<p>An important part of Tensorflow is that it is supposed to be fast. With a suitable installation, it works with CPUs, GPUs, or TPUs. Part of going fast means that it uses different code depending on your hardware. Some CPUs support operations that other CPUs do not, such as vectorized addition (adding multiple variab...
you are the stackoverflow assistant
What does tf.nn.conv2d do in tensorflow?
<p>Ok I think this is about the simplest way to explain it all.</p> <hr> <p>Your example is 1 image, size 2x2, with 1 channel. You have 1 filter, with size 1x1, and 1 channel (size is height x width x channels x number of filters). </p> <p>For this simple case the resulting 2x2, 1 channel image (size 1x2x2x1, number...
you are the stackoverflow assistant
Loading a trained Keras model and continue training
<p>Actually - <code>model.save</code> saves all information need for restarting training in your case. The only thing which could be spoiled by reloading model is your optimizer state. To check that - try to <code>save</code> and reload model and train it on training data.</p>
you are the stackoverflow assistant
How are the new tf.contrib.summary summaries in TensorFlow evaluated?
<p><em>answer moved from edit to self-answer as requested</em></p> <hr /> <p>I just played around with this a little bit, and it seems that if one combines <code>tf.control_dependencies</code> with <code>tf.record_summaries_every_n_global_steps</code> it behaves as expected and the summary only gets recorded every nth ...
you are the stackoverflow assistant
In Tensorflow, get the names of all the Tensors in a graph
<p>You can do</p> <pre><code>[n.name for n in tf.get_default_graph().as_graph_def().node] </code></pre> <p>Also, if you are prototyping in an IPython notebook, you can show the graph directly in notebook, see <code>show_graph</code> function in Alexander's Deep Dream <a href="http://nbviewer.jupyter.org/github/tensor...
you are the stackoverflow assistant
Should we do learning rate decay for adam optimizer
<p>It depends. ADAM updates any parameter with an individual learning rate. This means that every parameter in the network has a specific learning rate associated.</p> <p><em>But</em> the single learning rate for each parameter is computed using lambda (the initial learning rate) as an upper limit. This means that ever...
you are the stackoverflow assistant
TensorFlow, why there are 3 files after saving the model?
<p>Try this:</p> <pre><code>with tf.Session() as sess: saver = tf.train.import_meta_graph('/tmp/model.ckpt.meta') saver.restore(sess, "/tmp/model.ckpt") </code></pre> <p>The TensorFlow save method saves three kinds of files because it stores the <b>graph structure</b> separately from the <b>variable values</b...
you are the stackoverflow assistant
Difference between Variable and get_variable in TensorFlow
<p>I'd recommend to always use <code>tf.get_variable(...)</code> -- it will make it way easier to refactor your code if you need to share variables at any time, e.g. in a multi-gpu setting (see the multi-gpu CIFAR example). There is no downside to it. </p> <p>Pure <code>tf.Variable</code> is lower-level; at some point...
you are the stackoverflow assistant
TensorFlow, &quot;&#39;module&#39; object has no attribute &#39;placeholder&#39;&quot;
<p>If you have this error after an upgrade to TensorFlow 2.0, you can still use 1.X API by replacing:</p> <pre><code>import tensorflow as tf </code></pre> <p>by</p> <pre><code>import tensorflow.compat.v1 as tf tf.disable_v2_behavior() </code></pre>
you are the stackoverflow assistant
Meaning of buffer_size in Dataset.map , Dataset.prefetch and Dataset.shuffle
<p><strong>TL;DR</strong> Despite their similar names, these arguments have quite difference meanings. The <code>buffer_size</code> in <code>Dataset.shuffle()</code> can affect the randomness of your dataset, and hence the order in which elements are produced. The <code>buffer_size</code> in <code>Dataset.prefetch()</c...
you are the stackoverflow assistant
Keras split train test set when using ImageDataGenerator
<p>Keras has now added Train / validation split from a single directory using ImageDataGenerator:</p> <pre><code>train_datagen = ImageDataGenerator(rescale=1./255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, validation_split=0.2) # set validation split train_generator = train_datagen.flow_f...
you are the stackoverflow assistant
What&#39;s the purpose of tf.app.flags in TensorFlow?
<p>The <code>tf.app.flags</code> module is presently a thin wrapper around <strike>python-gflags, so the <a href="https://github.com/gflags/python-gflags">documentation for that project</a> is the best resource for how to use it</strike> <a href="https://docs.python.org/2.7/library/argparse.html"><code>argparse</code><...
you are the stackoverflow assistant
Tensorflow Strides Argument
<p>The pooling and convolutional ops slide a "window" across the input tensor. Using <a href="https://www.tensorflow.org/versions/master/api_docs/python/nn.html#conv2d"><code>tf.nn.conv2d</code></a> as an example: If the input tensor has 4 dimensions: <code>[batch, height, width, channels]</code>, then the convolutio...
you are the stackoverflow assistant
What&#39;s the difference between sparse_softmax_cross_entropy_with_logits and softmax_cross_entropy_with_logits?
<p>Having two different functions is a <strong>convenience</strong>, as they produce the same result. </p> <p>The difference is simple:</p> <ul> <li>For <code>sparse_softmax_cross_entropy_with_logits</code>, labels must have the shape [batch_size] and the dtype int32 or int64. Each label is an int in range <code>[0,...
you are the stackoverflow assistant
Will scikit-learn utilize GPU?
<p>Tensorflow only uses GPU if it is built against Cuda and CuDNN. By default it does not use GPU, especially if it is running inside Docker, unless you use <a href="https://github.com/NVIDIA/nvidia-docker" rel="noreferrer">nvidia-docker</a> and an image with a built-in support.</p> <p>Scikit-learn is not intended to b...
you are the stackoverflow assistant
Can Keras with Tensorflow backend be forced to use CPU or GPU at will?
<p>If you want to force Keras to use CPU</p> <h2>Way 1</h2> <pre><code>import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152 os.environ["CUDA_VISIBLE_DEVICES"] = "" </code></pre> <p>before Keras / Tensorflow is imported.</p> <h2>Way 2</h2> <p>Run your script as</p> <pre><code>$ CUDA_VISIBLE_...
you are the stackoverflow assistant
How to apply gradient clipping in TensorFlow?
<p>Gradient clipping needs to happen after computing the gradients, but before applying them to update the model's parameters. In your example, both of those things are handled by the <code>AdamOptimizer.minimize()</code> method.</p> <p>In order to clip your gradients you'll need to explicitly compute, clip, and apply ...
you are the stackoverflow assistant
ImportError: No module named tensorflow
<p>Try installing tensorflow again with the whatever version you want and with option --ignore-installed like:</p> <pre><code>pip install tensorflow==1.2.0 --ignore-installed </code></pre> <p>I solved same issue using this command.</p>
you are the stackoverflow assistant
Does model.compile() initialize all the weights and biases in Keras (tensorflow backend)?
<p><strong>When to use?</strong></p> <p><strong>If</strong> you're using <code>compile</code>, surely it must be after <code>load_model()</code>. After all, you need a model to compile. (PS: <code>load_model</code> automatically compiles the model with the optimizer that was saved along with the model)</p> <p><strong...
you are the stackoverflow assistant
What is the difference between sparse_categorical_crossentropy and categorical_crossentropy?
<p>Simply:</p> <ul> <li><code>categorical_crossentropy</code> (<code>cce</code>) produces a one-hot array containing the probable match for each category,</li> <li><code>sparse_categorical_crossentropy</code> (<code>scce</code>) produces a category index of the <em>most likely</em> matching category.</li> </ul> <p>Cons...
you are the stackoverflow assistant
Can I use TensorBoard with Google Colab?
<p><strong>EDIT:</strong> You probably want to give the official <a href="https://github.com/tensorflow/tensorboard/blob/a49abcbb91467a693d068b42f45b3f7b1880deca/docs/tensorboard_in_notebooks.ipynb" rel="nofollow noreferrer"><code>%tensorboard</code> magic</a> a go, available from TensorFlow 1.13 onward.</p> <hr /> <p...
you are the stackoverflow assistant
How to set adaptive learning rate for GradientDescentOptimizer?
<p>First of all, <code>tf.train.GradientDescentOptimizer</code> is designed to use a constant learning rate for all variables in all steps. TensorFlow also provides out-of-the-box adaptive optimizers including the <a href="http://www.tensorflow.org/api_docs/python/train.html#AdagradOptimizer"><code>tf.train.AdagradOpti...
you are the stackoverflow assistant
TensorFlow saving into/loading a graph from a file
<p>There are many ways to approach the problem of saving a model in TensorFlow, which can make it a bit confusing. Taking each of your sub-questions in turn:</p> <ol> <li><p>The checkpoint files (produced e.g. by calling <a href="https://www.tensorflow.org/api_docs/python/tf/train/Saver#save" rel="noreferrer"><code>sa...
you are the stackoverflow assistant
What is the difference between np.mean and tf.reduce_mean?
<p>The functionality of <code>numpy.mean</code> and <code>tensorflow.reduce_mean</code> are the same. They do the same thing. From the documentation, for <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.mean.html" rel="noreferrer">numpy</a> and <a href="https://www.tensorflow.org/api_docs/python/tf/re...
you are the stackoverflow assistant
What does global_step mean in Tensorflow?
<p><code>global_step</code> refers to the number of batches seen by the graph. Every time a batch is provided, the weights are updated in the direction that minimizes the loss. <code>global_step</code> just keeps track of the number of batches seen so far. When it is passed in the <code>minimize()</code> argument list,...
you are the stackoverflow assistant
AttributeError: &#39;Tensor&#39; object has no attribute &#39;numpy&#39;
<p>Since the accepted answer did not solve the problem for me so I thought it might be helpful for some people who face the problem and that already have tensorflow version &gt;= 2.2.0 and eager execution enabled.</p> <p>The issue seems to be that for certain functions during the fitting <code>model.fit()</code> the <c...
you are the stackoverflow assistant
How to get stable results with TensorFlow, setting random seed
<p>Setting the current TensorFlow random seed affects the current default graph only. Since you are creating a new graph for your training and setting it as default (<code>with g.as_default():</code>), you must set the random seed within the scope of that <code>with</code> block.</p> <p>For example, your loop should l...
you are the stackoverflow assistant
Tensorflow set CUDA_VISIBLE_DEVICES within jupyter
<p>You can set environment variables in the notebook using <code>os.environ</code>. Do the following before initializing TensorFlow to limit TensorFlow to first GPU.</p> <pre><code>import os os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" # see issue #152 os.environ["CUDA_VISIBLE_DEVICES"]="0" </code></pre> <p>You can...
you are the stackoverflow assistant
How to get Tensorflow tensor dimensions (shape) as int values?
<p>To get the shape as a list of ints, do <code>tensor.get_shape().as_list()</code>.</p> <p>To complete your <code>tf.shape()</code> call, try <code>tensor2 = tf.reshape(tensor, tf.TensorShape([num_rows*num_cols, 1]))</code>. Or you can directly do <code>tensor2 = tf.reshape(tensor, tf.TensorShape([-1, 1]))</code> whe...
you are the stackoverflow assistant
How to solve &quot;AttributeError: module &#39;google.protobuf.descriptor&#39; has no attribute &#39;_internal_create_key&quot;?
<p>The protoc version I got through <code>pip show protobuf</code> and <code>protoc --version</code> were different. The version in pip was a bit outdated.</p> <p>After I upgraded the pip version with</p> <pre class="lang-sh prettyprint-override"><code>pip install --upgrade protobuf </code></pre> <p>the problem was sol...
you are the stackoverflow assistant
What does batch, repeat, and shuffle do with TensorFlow Dataset?
<p>Update: <a href="https://colab.research.google.com/drive/1VS6-dYk3YAzoRmALhgTK7bb2_tBPrB4c?usp=sharing" rel="noreferrer">Here</a> is a small collaboration notebook for demonstration of this answer.</p> <hr /> <p>Imagine, you have a dataset: <code>[1, 2, 3, 4, 5, 6]</code>, then:</p> <p><strong>How ds.shuffle() works...
you are the stackoverflow assistant
When importing tensorflow, I get the following error: No module named &#39;numpy.core._multiarray_umath&#39;
<p>I also had the same issue. It got resloved once I upgraded the numpy from 1.15.4 to 1.16.1.</p> <p>If you're using pip: <code>pip install numpy --upgrade</code></p> <p>Numpy that came with Anaconda3 is of version 1.15.4. so i upgraded and it worked.</p> <hr /> <p>Side note: if you're also using <strong>scikit-image<...
you are the stackoverflow assistant
Using a pre-trained word embedding (word2vec or Glove) in TensorFlow
<p>There are a few ways that you can use a pre-trained embedding in TensorFlow. Let's say that you have the embedding in a NumPy array called <code>embedding</code>, with <code>vocab_size</code> rows and <code>embedding_dim</code> columns and you want to create a tensor <code>W</code> that can be used in a call to <a h...
you are the stackoverflow assistant
How to stack multiple lstm in keras?
<p>You need to add <code>return_sequences=True</code> to the first layer so that its output tensor has <code>ndim=3</code> (i.e. batch size, timesteps, hidden state).</p> <p>Please see the following example:</p> <pre><code># expected input data shape: (batch_size, timesteps, data_dim) model = Sequential() model.add(L...
you are the stackoverflow assistant
How to choose cross-entropy loss in TensorFlow?
<h2>Preliminary facts</h2> <ul> <li><p>In functional sense, the <a href="https://stats.stackexchange.com/q/233658/130598">sigmoid is a partial case of the softmax function</a>, when the number of classes equals 2. Both of them do the same operation: transform the logits (see below) to probabilities.</p> <p>In simple ...
you are the stackoverflow assistant
How to add regularizations in TensorFlow?
<p>As you say in the second point, using the <code>regularizer</code> argument is the recommended way. You can use it in <code>get_variable</code>, or set it once in your <code>variable_scope</code> and have all your variables regularized.</p> <p>The losses are collected in the graph, and you need to manually add them ...
you are the stackoverflow assistant
Meaning of inter_op_parallelism_threads and intra_op_parallelism_threads
<p>The <code>inter_op_parallelism_threads</code> and <code>intra_op_parallelism_threads</code> options are documented in the <a href="https://github.com/tensorflow/tensorflow/blob/26b4dfa65d360f2793ad75083c797d57f8661b93/tensorflow/core/protobuf/config.proto#L165" rel="noreferrer">source of the <code>tf.ConfigProto</co...
you are the stackoverflow assistant
How do display different runs in TensorBoard?
<p>In addition to TensorBoard scanning subdirectories (so you can pass a directory containing the directories with your runs), you can also pass multiple directories to TensorBoard explicitly and give custom names (example taken from the --help output):</p> <pre><code>tensorboard --logdir=name1:/path/to/logs/1,name2:/p...
you are the stackoverflow assistant
How to remove cuda completely from ubuntu?
<p>From cuda 11.4 onwards, an uninstaller script has been provided. Use it for the uninstallation:</p> <pre><code># To uninstall cuda sudo /usr/local/cuda-11.4/bin/cuda-uninstaller # To uninstall nvidia sudo /usr/bin/nvidia-uninstall </code></pre> <p>If you are using cuda 11.3 or earlier refer to the section below for...
you are the stackoverflow assistant
What is the difference between Dataset.from_tensors and Dataset.from_tensor_slices?
<p><code>from_tensors</code> combines the input and returns a dataset with a single element:</p> <pre><code>&gt;&gt;&gt; t = tf.constant([[1, 2], [3, 4]]) &gt;&gt;&gt; ds = tf.data.Dataset.from_tensors(t) &gt;&gt;&gt; [x for x in ds] [&lt;tf.Tensor: shape=(2, 2), dtype=int32, numpy= array([[1, 2], [3, 4]], dty...
you are the stackoverflow assistant
Higher validation accuracy, than training accurracy using Tensorflow and Keras
<p>This happens when you use <code>Dropout</code>, since the behaviour when training and testing are different. </p> <p>When training, a percentage of the features are set to zero (50% in your case since you are using <code>Dropout(0.5)</code>). When testing, all features are used (and are scaled appropriately). So th...
you are the stackoverflow assistant
Using Keras &amp; Tensorflow with AMD GPU
<p>I'm writing an OpenCL 1.2 backend for Tensorflow at <a href="https://github.com/hughperkins/tensorflow-cl" rel="noreferrer">https://github.com/hughperkins/tensorflow-cl</a></p> <p>This fork of tensorflow for OpenCL has the following characteristics:</p> <ul> <li>it targets any/all OpenCL 1.2 devices. It doesnt ne...
you are the stackoverflow assistant
How can I use a pre-trained neural network with grayscale images?
<p>The model's architecture <strong>cannot</strong> be changed because the weights have been trained for a specific input configuration. Replacing the first layer with your own would pretty much render the rest of the weights useless. </p> <p>-- Edit: elaboration suggested by Prune--<br> CNNs are built so that as they...
you are the stackoverflow assistant
What is the purpose of the Tensorflow Gradient Tape?
<p>With eager execution enabled, Tensorflow will calculate the values of tensors as they occur in your code. This means that it won't precompute a static graph for which inputs are fed in through placeholders. This means to back propagate errors, you have to keep track of the gradients of your computation and then appl...
you are the stackoverflow assistant
On Windows, running &quot;import tensorflow&quot; generates No module named &quot;_pywrap_tensorflow&quot; error
<p>The problem was the cuDNN Library for me - for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working - I used cudnn-8.0-windows10-x64-v5.1 - ALL GOOD!</p> <p>My setup working with Win10 64 and the Nvidia GTX780M:</p> <ul> <li>Be sure you have the lib MSVCP140.DLL by checking your system/path - if not get it...
you are the stackoverflow assistant
How to do Xavier initialization on TensorFlow
<p>Since version 0.8 there is a Xavier initializer, <a href="https://www.tensorflow.org/versions/r0.11/api_docs/python/contrib.layers.html#xavier_initializer">see here for the docs</a>.</p> <p>You can use something like this:</p> <pre><code>W = tf.get_variable("W", shape=[784, 256], initializer=tf.contrib....
you are the stackoverflow assistant
How to assign a value to a TensorFlow variable?
<p>In TF1, the statement <a href="https://www.tensorflow.org/api_docs/python/tf/compat/v1/Variable#assign" rel="noreferrer"><code>x.assign(1)</code></a> does not actually assign the value <code>1</code> to <code>x</code>, but rather creates a <a href="https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Operati...
you are the stackoverflow assistant
How to *actually* read CSV data in TensorFlow?
<p>I think you are mixing up imperative and graph-construction parts here. The operation <code>tf.train.shuffle_batch</code> creates a new queue node, and a single node can be used to process the entire dataset. So I think you are hanging because you created a bunch of <code>shuffle_batch</code> queues in your for loop...
you are the stackoverflow assistant
In Keras, what exactly am I configuring when I create a stateful `LSTM` layer with N `units`?
<p>You can check <a href="https://stackoverflow.com/questions/38714959/understanding-keras-lstms/38737941#38737941">this question</a> for further information, although it is based on Keras-1.x API.</p> <p>Basically, the <code>unit</code> means the dimension of the inner cells in LSTM. Because in LSTM, the dimension of...
you are the stackoverflow assistant
RuntimeError: tf.placeholder() is not compatible with eager execution
<p>I found an easy solution here: <a href="https://stackoverflow.com/questions/53429896/disable-tensorflow-eager-execution">disable Tensorflow eager execution</a></p> <p>Basicaly it is:</p> <p><code>tf.compat.v1.disable_eager_execution()</code></p> <p>With this, you disable the default activate eager execution and y...
you are the stackoverflow assistant
Making predictions with a TensorFlow model
<p>In the "<a href="https://www.tensorflow.org/get_started/mnist/pros" rel="noreferrer">Deep MNIST for Experts</a>" example, see this line:</p> <blockquote> <p>We can now implement our regression model. It only takes one line! We multiply the vectorized input images x by the weight matrix W, add the bias b, and ...
you are the stackoverflow assistant
How to inspect a Tensorflow .tfrecord file?
<p>Found it!</p> <pre><code>import tensorflow as tf for example in tf.python_io.tf_record_iterator("data/foobar.tfrecord"): print(tf.train.Example.FromString(example)) </code></pre> <p>You can also add:</p> <pre><code>from google.protobuf.json_format import MessageToJson ... jsonMessage = MessageToJson(tf.train...
you are the stackoverflow assistant
Clearing Tensorflow GPU memory after model execution
<p>You can use numba library to release all the gpu memory</p> <pre class="lang-sh prettyprint-override"><code>pip install numba </code></pre> <pre class="lang-py prettyprint-override"><code>from numba import cuda device = cuda.get_current_device() device.reset() </code></pre> <p>This will release all the memory</p>
you are the stackoverflow assistant
How do I disable TensorFlow&#39;s eager execution?
<p>Assume you are using Tensorflow 2.0 preview release which has eager execution enabled by default. There is a <code>disable_eager_execution()</code> in v1 API, which you can put in the front of your code like:</p> <pre class="lang-py prettyprint-override"><code>import tensorflow as tf tf.compat.v1.disable_eager_...
you are the stackoverflow assistant
How to import keras from tf.keras in Tensorflow?
<p>Use the keras module from tensorflow like this:</p> <p><code>import tensorflow as tf</code></p> <p>Import classes</p> <p><code>from tensorflow.python.keras.layers import Input, Dense</code></p> <p>or use directly</p> <p><code>dense = tf.keras.layers.Dense(...)</code></p> <p><strong>EDIT Tensorflow 2</strong></...
you are the stackoverflow assistant
Failed to get convolution algorithm. This is probably because cuDNN failed to initialize,
<p>I've seen this error message for three different reasons, with different solutions:</p> <h2>1. You have cache issues</h2> <p>I regularly work around this error by shutting down my python process, removing the <code>~/.nv</code> directory (on linux, <code>rm -rf ~/.nv</code>), and restarting the Python process. I don...
you are the stackoverflow assistant
NotImplementedError: Cannot convert a symbolic Tensor (2nd_target:0) to a numpy array
<p>For me, the issue occurred when upgrading from <code>numpy 1.19</code> to <code>1.20</code> and using <code>ray</code>'s RLlib, which uses <code>tensorflow 2.2</code> internally. Simply downgrading with</p> <pre><code>pip install numpy==1.19.5 </code></pre> <p>solved the problem; the error did not occur anymore.</p>...
you are the stackoverflow assistant
Get the value of some weights in a model trained by TensorFlow
<p>In TensorFlow, trained weights are represented by <a href="https://www.tensorflow.org/versions/r0.7/api_docs/python/state_ops.html#Variable"><code>tf.Variable</code></a> objects. If you created a <code>tf.Variable</code>&mdash;e.g. called <code>v</code>&mdash;yourself, you can get its value as a NumPy array by calli...
you are the stackoverflow assistant
How could I use batch normalization in TensorFlow?
<p><strong>Update July 2016</strong> The easiest way to use batch normalization in TensorFlow is through the higher-level interfaces provided in either <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/layers.py" rel="noreferrer">contrib/layers</a>, <a href="http://t...
you are the stackoverflow assistant
tensorflow:AttributeError: &#39;module&#39; object has no attribute &#39;mul&#39;
<p>According to the <a href="https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md" rel="noreferrer">tensorflow 1.0.0 release notes</a>, </p> <blockquote> <p><code>tf.mul</code>, <code>tf.sub</code> and <code>tf.neg</code> are deprecated in favor of <code>tf.multiply</code>, <code>tf.subtract</code> and <c...
you are the stackoverflow assistant
What is the default kernel initializer in tf.layers.conv2d and tf.layers.dense?
<p>Great question! It is quite a trick to find out!</p> <ul> <li>As you can see, it is not documented in <a href="https://www.tensorflow.org/api_docs/python/tf/layers/conv2d" rel="noreferrer"><code>tf.layers.conv2d</code></a></li> <li>If you look at the definition of <a href="https://github.com/tensorflow/tensorflow...
you are the stackoverflow assistant
What is the proper way to install TensorFlow on Apple M1 in 2022
<h1>Conda Environment YAMLs</h1> <h2>TensorFlow 2.13+</h2> <p>Distilling <a href="https://developer.apple.com/metal/tensorflow-plugin/" rel="nofollow noreferrer">the official directions from Apple</a> (as of 24 November 2024), one would create an environment using the following YAML:</p> <p><strong>tf-metal-arm64.yaml<...
you are the stackoverflow assistant
End of preview. Expand in Data Studio

TensorFlow, PyTorch, and Keras Framework Dataset: StackOverflow & GitHub

Dataset Overview

This dataset contains a collection of questions, answers, and code snippets related to the TensorFlow, PyTorch, and Keras frameworks, sourced from StackOverflow and GitHub repositories. It provides a comprehensive resource for researchers, practitioners, and developers interested in analyzing and enhancing their understanding of these popular machine learning frameworks.

Data Sources

  • StackOverflow posts: User-generated questions and answers focused on common issues, optimizations, and best practices in TensorFlow, PyTorch, and Keras.
  • GitHub repositories: Relevant code snippets, documentation, and discussions from open-source repositories that leverage these frameworks.

Use Cases

The dataset is designed to support various tasks such as:

  • Natural Language Processing (NLP)
  • Sentiment analysis
  • Code summarization
  • Question-answering models

It is a valuable resource for AI research and development related to deep learning and machine learning frameworks.

Data Structure

  • StackOverflow Data: Contains questions, answers, and comments. Each entry includes metadata such as post ID, user ID, score, and relevant tags.
  • GitHub Data: Includes code snippets, repository metadata, issues, and pull requests.

License

This dataset is made available for research and educational purposes. Please refer to the respective licenses of StackOverflow and GitHub for usage terms.

Acknowledgements

We would like to acknowledge StackOverflow and GitHub for providing the rich source of data that this dataset is based on.

Citation

If you use this dataset in your research, please cite it as follows:

Downloads last month
27