{"QuestionId":49112683,"AnswerCount":1,"Tags":"","CreationDate":"2018-03-05T14:28:33.610","AcceptedAnswerId":49113307.0,"OwnerUserId":5396681.0,"Title":"AttributeError when using theano backend with CPU","Body":"

I am trying to run this<\/a> python notebook where a well known convolutional neural network is implemented using Keras. The author uses theano as a backend and uses his cpu device. Because my CPU is not supported by CUDA (which is needed to use it) i will try to use my gpu (to begin with). \nI installed keras and theano plus the needed requirements following this<\/a> link. I skipped the gpu configuration since I want to use my GPU. <\/p>\n\n

To use my GPU I changed the device flag in one of the first lines resulting in this:<\/p>\n\n

<\/pre>\n\n

This gives me an error: <\/p>\n\n

<\/pre>\n\n

I found solutions but primarily for GPU users. I also read somewhere<\/a> that I have to delete a $HOME\/.theanorc file, however I cannot find this file. <\/p>\n\n

Can anyone shed some light on what causes this error and how to solve this?<\/p>\n","answers":[{"AnswerId":"49113307","CreationDate":"2018-03-05T15:00:26.463","ParentId":null,"OwnerUserId":"3801361","Title":null,"Body":"

The reason it says \"AttributeError: ('This name is already taken', 'floatX')\"<\/code> \nis most likely because the floatX<\/code> is already defined in .theanorc.txt<\/code> file. <\/p>\n\n

You can either remove \"floatX=float32, \"<\/code> from <\/p>\n\n

os.environ['THEANO_FLAGS'] = 'mode=FAST_RUN, device=cpu, floatX=float32, optimizer=fast_compile'\n<\/code><\/pre>\n\n

and repeat same for similar other attributes.<\/p>\n\n

Better alternative than that is: run python and type, <\/p>\n\n

import os \nprint(os.path.expanduser('~\/.theanorc.txt'))\n<\/code><\/pre>\n\n

It will show where .theanorc.txt<\/code> file is located in windows<\/p>\n"}]} {"QuestionId":49112722,"AnswerCount":1,"Tags":"

this is may problem.\nI can load the audio_binary like this\n\nbut when I try to read the wav with this:<\/p>\n\n

<\/pre>\n\n

I get error <\/p>\n\n

I have also tried doing this: <\/p>\n\n

<\/pre>\n\n

and I get this error <\/p>\n\n

By the way I'm using tensorflow-gpu in a Jupyter notebook.<\/p>\n\n

Any help would be highly appreciated.\nThanks!<\/p>\n","answers":[{"AnswerId":"49118533","CreationDate":"2018-03-05T20:04:22.400","ParentId":null,"OwnerUserId":"4541944","Title":null,"Body":"

In case someone has the same problem.\nI was using TIMIT database, and their files, althought their were .wav, the have a differnet codification (NIST). I have to change them to RIFF, like this forfiles \/s \/m *.wav \/c \"cmd \/c sph2pipe -f wav @file @fnameRIFF.wav\"<\/code>\nand the use the second command contrib_audio.decode_wav(...)<\/code><\/p>\n\n

Based on this answer: \nChange huge amount of data from NIST to RIFF wav file<\/a><\/p>\n\n

And this page:\nhttp:\/\/soundfile.sapp.org\/doc\/WaveFormat\/<\/a><\/p>\n"}]} {"QuestionId":49112896,"AnswerCount":2,"Tags":"","CreationDate":"2018-03-05T14:38:39.607","AcceptedAnswerId":null,"OwnerUserId":9445883.0,"Title":"how to load saved checkpoint in Tf SLIM","Body":"

I am using TF-slim to train my own dataset. According to the tutorial, in the finetune_inception_v1_on_flowers.sh, I set the checkpoint path as .\/inception_resnet_v2.ckpt, and get lots of new checkpoints in another file folder, and the latest files are model.ckpt-332331.data-00000-of-00001,model.ckpt-332331.index, model.ckpt-332331.meta.<\/p>\n\n

now I want to change the learning rate to fine turing the latest check point, but I don't know how to load them in the finetune_inception_v1_on_flowers.sh because there are 3 files instead of one.<\/p>\n\n

<\/pre>\n\n
\n

NotFoundError (see above for traceback): Key\n InceptionResnetV2\/AuxLogits\/Conv2d_1b_1x1\/weights\/Adam not found in\n checkpoint [[Node: save\/RestoreV2_4 = RestoreV2[dtypes=[DT_FLOAT],\n _device=\"\/job:localhost\/replica:0\/task:0\/cpu:0\"](_recv_save\/Const_0, save\/RestoreV2_4\/tensor_names, save\/RestoreV2_4\/shape_and_slices)]]<\/p>\n<\/blockquote>\n\n

secondly, I removed the files from log directory ,then the error is :<\/p>\n\n

\n

DataLossError (see above for traceback): Unable to open table file\n \/media\/re\/7A308F7E308F405D\/xsj\/checkpoints\/model.ckpt-332331.data-00000-of-00001:\n Data loss: not an sstable (bad magic number): perhaps your file is in\n a different file format and you need to use a different restore\n operator? [[Node: save\/RestoreV2_5 = RestoreV2[dtypes=[DT_FLOAT],\n _device=\"\/job:localhost\/replica:0\/task:0\/cpu:0\"](_recv_save\/Const_0, save\/RestoreV2_5\/tensor_names, save\/RestoreV2_5\/shape_and_slices)]]<\/p>\n<\/blockquote>\n\n

Can anyone help me to solve the problem? Thank you very much!<\/p>\n","answers":[{"AnswerId":"51141088","CreationDate":"2018-07-02T17:29:31.210","ParentId":null,"OwnerUserId":"7032887","Title":null,"Body":"

When you do fine tune, just specify the directory ($CHECKPOINT_PATH) not any specific file, it will automatically get the path. <\/p>\n"},{"AnswerId":"54032606","CreationDate":"2019-01-04T03:01:07.210","ParentId":null,"OwnerUserId":"3926424","Title":null,"Body":"

As mentioned in https:\/\/www.tensorflow.org\/guide\/saved_model<\/a><\/p>\n\n

\n

There is not a physical file called \/tmp\/model.ckpt. It is the prefix\n of filenames created for the checkpoint. Users only interact with the\n prefix instead of physical checkpoint files.<\/p>\n<\/blockquote>\n\n

So you just need to set checkpoint path as .\/model.ckpt-332331<\/strong><\/p>\n"}]} {"QuestionId":49112941,"AnswerCount":2,"Tags":"","CreationDate":"2018-03-05T14:41:36.210","AcceptedAnswerId":null,"OwnerUserId":3654588.0,"Title":"Keras - Freezing A Model And Then Adding Trainable Layers","Body":"

I am taking a CNN model that is pretrained, and then trying to implement a CNN-LSTM with parallel CNNs all with the same weights from the pretraining.<\/p>\n\n\n\n

<\/pre>\n\n

_<\/p>\n\n

<\/pre>\n\n

Now, I will add to it and compile and show that the non-trainable all become trainable.<\/p>\n\n

<\/pre>\n\n

How am I supposed to freeze the layers in this case? I am almost 100% positive that I had working code in this format in an earlier keras version. It seems like this is the right direction, since you define a model and declare certain layers trainable, or not.<\/p>\n\n

Then you add layers, which are by default trainable. However, this seems to convert all the layers to trainable.<\/p>\n","answers":[{"AnswerId":"50877607","CreationDate":"2018-06-15T14:28:54.080","ParentId":null,"OwnerUserId":"4911718","Title":null,"Body":"

try adding<\/p>\n\n

    for layer in currmodel.layers[:5]:\n        layer.trainable = False\n<\/code><\/pre>\n"},{"AnswerId":"55908880","CreationDate":"2019-04-29T18:23:24.637","ParentId":null,"OwnerUserId":"5808706","Title":null,"Body":"

First print the layer numbers in you network<\/p>\n\n

for i,layer in enumerate(currmodel.layers):\n    print(i,layer.name)\n<\/code><\/pre>\n\n

Now check which layers are trainable and which are not<\/p>\n\n

for i,layer in enumerate(model.layers):\n    print(i,layer.name,layer.trainable)\n<\/code><\/pre>\n\n

Now you can set the parameter 'trainable' for the layers which you want. Let us say you want to train only last 2 layers out of total 6 (the numbering starts from 0) then you can write something like this<\/p>\n\n

for layer in model.layers[:5]:\n    layer.trainable=False\nfor layer in model.layers[5:]:\n    layer.trainable=True\n<\/code><\/pre>\n\n

To cross check try to print again and you will get the desired settings.<\/p>\n"}]} {"QuestionId":49113045,"AnswerCount":1,"Tags":"","CreationDate":"2018-03-05T14:47:09.083","AcceptedAnswerId":49114963.0,"OwnerUserId":9402546.0,"Title":"CNN training error in executingTensorflow Python for identification of images of dogs and cats","Body":"

When I try to train my CNN for identifying cats and dogs images in Python Tensorflow, first epoch is successfully executed but later an error crops up as given.Can anyone please help out for resolving this.\n I followed the blog and then moved on to adapting the CNN they had used to my problem, but it hasn't worked out very well.<\/p>\n\n

There also a dataset.py file that is used to load data of cats and dogs for training. I guess the error might be due to latest Tensorflow updates according to what I read on google but I am not sure as I am a beginner for CNN type of Neural Nets.<\/p>\n\n

CommandLine Log:<\/p>\n\n

<\/pre>\n\n

MyCode:<\/p>\n\n

<\/pre>\n","answers":[{"AnswerId":"49114963","CreationDate":"2018-03-05T16:21:58.747","ParentId":null,"OwnerUserId":"7352765","Title":null,"Body":"

The error occurs in the line saver.save(session, 'dogs-cats-model')<\/code>, just after showing progress. Now to fix this, change the path from 'dogs-cats-model'<\/code> to '.\/dogs-cats-model'<\/code>. This should fix it.<\/p>\n"}]} {"QuestionId":49113140,"AnswerCount":4,"Tags":"","CreationDate":"2018-03-05T14:52:22.863","AcceptedAnswerId":52101454.0,"OwnerUserId":5695374.0,"Title":"ImportError: cannot import name '_obtain_input_shape' from keras","Body":"

In Keras, <\/p>\n\n

I'm trying to import as follows: <\/p>\n\n

<\/pre>\n\n

However, I get the following error: <\/p>\n\n

\n

ImportError: cannot import name '_obtain_input_shape'<\/p>\n<\/blockquote>\n\n

The reason I'm trying to import _obtain_input_shape is so that I can determine the input shape(so as to load VGG-Face<\/a> as follows : <\/p>\n\n

I'm using it to determine the correct input shape of the input tensor as follow: <\/p>\n\n

<\/pre>\n\n

Please assist?\nThanks in advance. <\/p>\n","answers":[{"AnswerId":"51629187","CreationDate":"2018-08-01T08:56:55.937","ParentId":null,"OwnerUserId":"5803658","Title":null,"Body":"

This issue occured because of the version of keras.<\/p>\n\n

In my case, I was downgrade keras 2.2.2 to 2.2.0, and the problem was solved.<\/p>\n"},{"AnswerId":"54552476","CreationDate":"2019-02-06T11:22:14.010","ParentId":null,"OwnerUserId":"3861545","Title":null,"Body":"

for keras 2.2.4:\nChange the line like below to make it work.<\/p>\n\n

from keras_applications.imagenet_utils import _obtain_input_shape\n<\/code><\/pre>\n\n

Note: It is importing from keras_applications<\/strong> and does not from keras.applications<\/strong> as before.<\/p>\n"},{"AnswerId":"51870160","CreationDate":"2018-08-16T05:31:34.700","ParentId":null,"OwnerUserId":"7296941","Title":null,"Body":"

I have found a method that works well. You just use <\/p>\n\n

from keras_applications.imagenet_utils import _obtain_input_shape \n<\/code><\/pre>\n\n

Notice: It is keras_applications<\/code> instead of keras.application<\/code>.<\/p>\n"},{"AnswerId":"52101454","CreationDate":"2018-08-30T16:13:12.040","ParentId":null,"OwnerUserId":"4592059","Title":null,"Body":"

You don't have to downgrade Keras 2.2.2.<\/strong><\/p>\n\n

In Keras 2.2.2<\/code> there is no _obtain_input_shape<\/code> method in the keras.applications.imagenet_utils<\/code> module. You can find it under keras-applications<\/a> with the modul name keras_applications (underscore). <\/p>\n\n

So you don't have to downgrade your Keras to 2.2.0 just change:<\/p>\n\n

from keras.applications.imagenet_utils import _obtain_input_shape\n<\/code><\/pre>\n\n

to<\/p>\n\n

from keras_applications.imagenet_utils import _obtain_input_shape\n<\/code><\/pre>\n"}]}
{"QuestionId":49113476,"AnswerCount":2,"Tags":"","CreationDate":"2018-03-05T15:09:08.650","AcceptedAnswerId":null,"OwnerUserId":4787865.0,"Title":"Why use keras as backend instead of using tensorflow?","Body":"

I see that there are many similar functions between tensorflow and keras like argmax, boolean_mask...I wonder why people have to use keras as backend along with tensorflow instead of using tensorflow alone.<\/p>\n","answers":[{"AnswerId":"49114364","CreationDate":"2018-03-05T15:52:42.113","ParentId":null,"OwnerUserId":"7352765","Title":null,"Body":"

Keras is not a backend, but it is a high-level API for building and training Neural Networks. Keras is capable of running on top of Tensorflow, Theano and CNTK. Most of the people prefer Keras due to its simplicity compared to other libraries like Tensorflow. I recommend Keras for beginners in Deep Learning.<\/p>\n"},{"AnswerId":"49117487","CreationDate":"2018-03-05T18:50:24.773","ParentId":null,"OwnerUserId":"3969542","Title":null,"Body":"

\n

A Keras tensor is a tensor object from the underlying backend (Theano,\n TensorFlow or CNTK), which we augment with certain attributes that\n allow us to build a Keras model just by knowing the inputs and outputs\n of the model.<\/p>\n<\/blockquote>\n\n

Theano vs Tensorflow<\/strong><\/p>\n\n

Tensorflow is necessary if you wish to use coremltools. Apple has promised support for architectures created using Theano but I haven't seen it yet.<\/p>\n\n

Keras will require unique syntax sugar depending on the backend in use. I like the flexibility of Tensorflow input layers and easy-access to strong Google neural networks. <\/p>\n"}]} {"QuestionId":49113497,"AnswerCount":4,"Tags":"","CreationDate":"2018-03-05T15:10:15.097","AcceptedAnswerId":49124948.0,"OwnerUserId":9446361.0,"Title":"python tensorflow import dll load failed","Body":"

I installed latest python 3.6.4 x64 version <\/p>\n\n

and then installed tensorflow for cpu-only with pip3 <\/p>\n\n

<\/pre>\n\n

however when I tried to import tensorflow in python<\/p>\n\n

it showed me the error below<\/p>\n\n

I am sure that I have installed Microsoft Visual C++ 2015 Redistributable(x64)<\/p>\n\n

so it wll not be the problem of dll msvcp140.dll lost<\/p>\n\n

it say that \"DLL load failed with error code -1073741795\"<\/p>\n\n

so what is exactly the problem here<\/p>\n\n

i cannot find any other information about this error code<\/p>\n\n

my os : windows 7 enterprise with service pack 1 \/ 64 bit \/ intel core i5 M 540<\/p>\n\n

<\/pre>\n","answers":[{"AnswerId":"56410843","CreationDate":"2019-06-01T22:20:58.373","ParentId":null,"OwnerUserId":"1200914","Title":null,"Body":"

Probably, your CPU does not have the instructions for AVX (needed for all tensorflow binaries since 1.6). You can check that with some tool like CPU-Z. If that is the case, you can donwload the correct wheel here (use SSE2 binaries):<\/p>\n\n

tensorflow-windows-wheel<\/a><\/p>\n"},{"AnswerId":"54702852","CreationDate":"2019-02-15T04:50:34.170","ParentId":null,"OwnerUserId":"9255099","Title":null,"Body":"

I faced the same issue with tensorflow-1.12.0\nwhat i did was :<\/p>\n\n

    \n
  1. Install anaconda<\/li>\n
  2. open anaconda prompt<\/li>\n
  3. conda create -n tfp python=3.6<\/code><\/li>\n
  4. activate tfp<\/code><\/li>\n
  5. conda install tensorflow<\/code><\/li>\n
  6. python<\/code><\/li>\n
  7. Now check by importing tensorflow<\/li>\n<\/ol>\n\n

    the version i used was 3.6, but you can also try with 3.7\nHope it helps!<\/p>\n"},{"AnswerId":"54776622","CreationDate":"2019-02-19T23:42:03.427","ParentId":null,"OwnerUserId":"9666817","Title":null,"Body":"

    I downgraded tensorflow to 1.10.0 and it fixed the issue<\/p>\n"},{"AnswerId":"49124948","CreationDate":"2018-03-06T06:52:01.260","ParentId":null,"OwnerUserId":"9449544","Title":null,"Body":"

    I got same problem with tensorflow1.6-CPU on win7 64bit(Intel Core 2 Duo Cpu T6670 2.2GHz)<\/p>\n\n

    After I found this, and it solved my problem.<\/p>\n\n

    Reference this issue: https:\/\/github.com\/tensorflow\/tensorflow\/issues\/17386<\/a><\/p>\n\n

    Re-installed by this tensorflow-1.6.0-cp36-cp36m-win_amd64.whl: https:\/\/github.com\/fo40225\/tensorflow-windows-wheel\/tree\/master\/1.6.0\/py36\/CPU\/sse2<\/a><\/p>\n\n

    Hope this .whl may help you.<\/p>\n"}]} {"QuestionId":49113650,"AnswerCount":0,"Tags":"","CreationDate":"2018-03-05T15:17:37.423","AcceptedAnswerId":null,"OwnerUserId":2309643.0,"Title":"Strange jumps in val_loss for Keras mobile_net based model","Body":"

    I am trying to train a model based on MobileNet to do landmark detection for Dog Faces (output is a tensor with x\/y coordinates for the position of the eyes and the nose of the dog).<\/p>\n\n

    In my training, I am seeing the following graph for val_loss<\/strong>:<\/p>\n\n

    \"enter<\/a><\/p>\n\n

    Question<\/strong>: What is going on with the random spikes in val_loss? <\/p>\n\n

    My model looks like this:<\/p>\n\n

    <\/pre>\n\n

    Further questions<\/strong>: Should I set epsilon to be an even bigger number in my optimizer? Will my model suffer if I make epsilon larger?<\/p>\n\n

    Should I try a different loss function?<\/p>\n\n

    Is the model itself at fault? <\/p>\n\n

    Should I try different top layers for my model?<\/p>\n\n


    \n\n

    Update<\/strong>: Removing the \"relu\" activation resulted both in no more funky jumps in val_loss, but also in a model with lower loss and even better precision! WOOHOO!<\/p>\n\n

    Here's the val_loss<\/strong> value after removing \"relu\" from the top layers (and no other changes).<\/p>\n\n

    \"enter<\/a><\/p>\n","answers":[]} {"QuestionId":49114094,"AnswerCount":2,"Tags":"","CreationDate":"2018-03-05T15:39:54.803","AcceptedAnswerId":49151677.0,"OwnerUserId":2317732.0,"Title":"How to build tensorflow object detection model for custom classes and also include the 90 classess the SSD Mobilenet model contains","Body":"

    I am building a new tensorflow model based off of SSD V1 coco model in order to perform real time object detection in a video but i m trying to find if there is a way to build a model where I can add a new class to the existing model so that my model has all those 90 classes available in SSD MOBILENET COCO v1 model and also contains the new classes that i want to classify.<\/p>\n\n

    For example, I have created training data for two classes: man, woman\nNow, I built a new tensorflow model that identifies a man and\/or woman in a video. However, my model does not have the other 90 classes present in original SSD Mobilenet model. I am looking for a way to concatenate both models or pass more than one model to my code to detect the objects.<\/p>\n\n

    If you have any questions or if I am not clear, please feel free to probe me further.<\/p>\n","answers":[{"AnswerId":"49151677","CreationDate":"2018-03-07T12:12:48.153","ParentId":null,"OwnerUserId":"9428127","Title":null,"Body":"

      \n
    1. The only way i find is you need to get dataset of SSD Mobilenet model on which it was trained. <\/li>\n
    2. Make sure all the images are present in one directory and annotations in another directory.<\/li>\n
    3. We should have a corresponding annotation file for each image file \nex: myimage.jpg and myimage.xml<\/li>\n
    4. If all the images of your customed dataset are of same formate with SSD Mobilenet model then annotate it with a tool called LabelImg. <\/li>\n
    5. Add that images and annotated files to respective images and annotations directory where we have already saved SSD Mobilenet.<\/li>\n
    6. Try regenerate new TFrecord and continue with remaining procedure on it. <\/li>\n<\/ol>\n"},{"AnswerId":"50797307","CreationDate":"2018-06-11T12:04:25.790","ParentId":null,"OwnerUserId":"9442808","Title":null,"Body":"

      You can use transfer learning with Tensorflow API.\nTransfer learning allows you to load re-trained network and modify the fully connected layer by introducing your classes.\nThere is full description for this in the following references:<\/p>\n\n

        \n
      1. Codelab<\/a><\/li>\n
      2. A good explanation here<\/a><\/li>\n
      3. Tensorflow API here<\/a> for more details <\/li>\n<\/ol>\n\n

        Also you can use google cloud platform<\/a> for better and faster results:<\/p>\n\n

        I wish this helps you.<\/p>\n"}]} {"QuestionId":49114306,"AnswerCount":1,"Tags":"","CreationDate":"2018-03-05T15:50:14.313","AcceptedAnswerId":49115521.0,"OwnerUserId":9422652.0,"Title":"Avoiding duplicating graph in tensorflow (LSTM model)","Body":"

        I have the following simplified code (actually, unrolled LSTM model):<\/p>\n\n

        <\/pre>\n\n

        Whenever I run the last line, it seems that it changes the graph. But I don't want the graph changes. Actually my code is different and is a neural network model but it is too huge, so I've added the above code. I want to call the without changing the graph of model but it changes. I read about variable scope in but it seems that I've not understand it at all.<\/p>\n","answers":[{"AnswerId":"49115521","CreationDate":"2018-03-05T16:51:30.967","ParentId":null,"OwnerUserId":"712995","Title":null,"Body":"

        You should take a look at the source code of tf.nn.dynamic_rnn<\/code>, specifically _dynamic_rnn_loop<\/code> function at python\/ops\/rnn.py<\/code><\/a> - it's solving the same problem. In order not blow up the graph, it's using tf.while_loop<\/code> to reuse the same graph ops for new data. But this approach adds several restrictions, namely the shape of tensors that are passing through in a loop must be invariant<\/em>. See the examples in tf.while_loop<\/code><\/a> documentation:<\/p>\n\n

        i0 = tf.constant(0)\nm0 = tf.ones([2, 2])\nc = lambda i, m: i < 10\nb = lambda i, m: [i+1, tf.concat([m, m], axis=0)]\ntf.while_loop(\n    c, b, loop_vars=[i0, m0],\n    shape_invariants=[i0.get_shape(), tf.TensorShape([None, 2])])\n<\/code><\/pre>\n"}]}
        {"QuestionId":49115391,"AnswerCount":3,"Tags":"","CreationDate":"2018-03-05T16:43:45.640","AcceptedAnswerId":49121818.0,"OwnerUserId":8265119.0,"Title":"ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory when installing tensor flow on Ubuntu 16.04.03","Body":"

        I am trying to install tensorflow with cuda and gpu support. When I try to import it, I get the following error:<\/p>\n\n

        <\/pre>\n\n

        this error occurs when I type this command in:<\/p>\n\n

        <\/pre>\n\n

        Can you please help me solve this problem<\/p>\n","answers":[{"AnswerId":"49121818","CreationDate":"2018-03-06T00:55:27.483","ParentId":null,"OwnerUserId":"4790871","Title":null,"Body":"

        This is almost always a missing path in your LD_LIBRARY_PATH<\/code>. Find libcublas.so.9.0<\/code> on your system (start looking under \/usr\/local<\/code>). <\/p>\n\n

        If you don't find it, then install the CUDA 9.0 Toolkit (note that with TF 1.5 you want 9.0 and not 9.1, a common gotcha, at least common in-so-far as I made that mistake myself).<\/p>\n\n

        https:\/\/developer.nvidia.com\/cuda-90-download-archive<\/a><\/p>\n\n

        If you have it, then update your LD_LIBRARY_PATH<\/code> to point to the appropriate lib<\/code> directory.<\/p>\n\n

        If you've done either of those and are now getting a similar looking error for a cudnn related library, then repeat that process for the CUDNN library.<\/p>\n\n

        https:\/\/developer.nvidia.com\/cudnn<\/a><\/p>\n\n

        I think the latest version works. Tensorflow depends on both CUDA toolkit and the CuDNN library extension.<\/p>\n\n

        Note that you can install all of this in userspace too (sudo is typical, but not required).<\/p>\n"},{"AnswerId":"54233711","CreationDate":"2019-01-17T10:20:24.377","ParentId":null,"OwnerUserId":"5102670","Title":null,"Body":"

        To easily find the libcublas<\/code> file, run sudo find \/ -iname 'libcublas*'<\/code>. Then add the path to the folder containing that file into LD_LIBRARY_PATH<\/code>.<\/p>\n"},{"AnswerId":"52084468","CreationDate":"2018-08-29T19:04:38.703","ParentId":null,"OwnerUserId":"5001625","Title":null,"Body":"

        I had cuda-9.0<\/code> installed and the LD_LIBRARY_PATH<\/code> was pointing to the correct location. Turned out that the permission of the folder \/usr\/local\/cuda-9.0<\/code> was wrong. I could not even cd<\/code> to the folder. I changed the owner of the cuda-9.0<\/code> from root<\/code> to my-user-name<\/code> and after that python was able to find the missing library.<\/p>\n"}]} {"QuestionId":49115416,"AnswerCount":1,"Tags":"","CreationDate":"2018-03-05T16:45:29.703","AcceptedAnswerId":49115512.0,"OwnerUserId":556014.0,"Title":"How to use a tensorflow tensor value in a formula?","Body":"

        I have a quick question. I am developing a model in tensorflow, and need to use the iteration number in a formula during the construction phase. I know how to use global_step, but I am not using an already existing optimizer. \nI am calculating my own gradients with<\/p>\n\n

        <\/pre>\n\n

        and then using<\/p>\n\n

        <\/pre>\n\n

        and would like to use the epoch value in the formula before updating my weights. How can I do it in the best way possible? I have a sess.run() part and would like to pass to the model the epoch number, but cannot directly use a tensor.\nFrom my run call<\/p>\n\n

        <\/pre>\n\n

        I would like to pass the epoch number. How do you usually do it?<\/p>\n\n

        Thanks in advance, Umberto<\/p>\n\n

        EDIT<\/strong>:<\/p>\n\n

        Thanks for the hints. So seems to work<\/p>\n\n

        <\/pre>\n\n

        but I still have to see if that is what I need and if is working as intended. Ideas and Feedback would be great!<\/p>\n","answers":[{"AnswerId":"49115512","CreationDate":"2018-03-05T16:51:06.750","ParentId":null,"OwnerUserId":"5471520","Title":null,"Body":"

        You can define epoch<\/code> as a non-trainable tf.Variable<\/code> in your graph and increment it at the end of each epoch. You can define an operation with tf.assign_add<\/code><\/a> to do the incrementation and run it end of each epoch.<\/p>\n\n

        Instead of rnd.normal<\/code> you will also need to use tf.random_normal<\/code><\/a> then.<\/p>\n\n

        Example:<\/p>\n\n

        epoch = tf.Variable(0, trainable=False) # 0 is initial value\n# increment by 1 when the next op is run\nepoch_incr_op = tf.assign_add(epoch, 1, name='incr_epoch')\n\n# Define any operations that depend on 'epoch'\n# Note we need to cast the integer 'epoch' to float to use in tf.pow\ngrad_W = grad_W + tf.random_normal(grad_W.shape, 0.0,\n                                  1.0\/tf.pow(1+tf.cast(epoch, tf.float32), 0.55))\n\n# Training loop\nwhile running_epoch:\n    _, _, cost_ = sess.run([new_W, new_b ,cost], \n       feed_dict = {X_: X_train_tr, Y: labels_, learning_rate: learning_r})\n\n# At end of epoch, increment epoch counter\nsess.run(epoch_incr_op)\n<\/code><\/pre>\n"}]}
        {"QuestionId":49115560,"AnswerCount":1,"Tags":"","CreationDate":"2018-03-05T16:53:17.540","AcceptedAnswerId":49121106.0,"OwnerUserId":170521.0,"Title":"Issue training RNN model with pytorch with trivial goal","Body":"

        I'm trying to train a simple RNN model with a trivial goal where the output matches a fixed vector regardless of the input<\/p>\n\n

        <\/pre>\n\n

        As it shows, the loss stays above 6 and never goes down. Notice also that I am biasing all the random inputs normal distributions by 5, so they are mostly positive numbers, so there should exist a weight distribution that approaches the goal output<\/p>\n\n

        What am I doing wrong in this example that is failing to output to approach the goal?<\/p>\n","answers":[{"AnswerId":"49121106","CreationDate":"2018-03-05T23:23:10.500","ParentId":null,"OwnerUserId":"5352399","Title":null,"Body":"

        Your fixed output is:<\/p>\n\n

        torch.FloatTensor([[0.0, 1.0, 0.0]])\n<\/code><\/pre>\n\n

        But you are using the following as the final layer in your RNN:<\/p>\n\n

        self.softmax = nn.LogSoftmax(dim=1)\n<\/code><\/pre>\n\n

        Does LogSoftmax<\/code> returns value in [0, 1]<\/code>? Althouhgh, you can use the Softmax<\/code> but I would recommend you to use the sign<\/a> function and transform -1<\/code> to 0.<\/p>\n"}]} {"QuestionId":49115790,"AnswerCount":1,"Tags":"","CreationDate":"2018-03-05T17:04:50.207","AcceptedAnswerId":null,"OwnerUserId":2309643.0,"Title":"How to write a conditional custom loss function for a Keras model","Body":"

        I am trying to build a model that can do landmark detection for Dog Faces - if a dog face is present, extract the x\/y coordinates of the eyes and the nose, otherwise tell me that there's no dog face.<\/p>\n\n

        I would like my output tensor to be of size 7:<\/p>\n\n