I have a deep learning python code (Anaconda3, Ubuntu 16.04) which uses TensorFlow for some machine learning algorithms on video inputs. It imports the following packages:
import time, os, glob, subprocess
import skvideo.io
import numpy as np
import tensorflow as tf
import time, cv2, librosa
import skvideo.io
import numpy as np
import tensorflow as tf
from sklearn.externals import joblib
When running, it get the following warning. How can I remove this warning (or hide it from printing)?
/home/user/anaconda3/lib/python3.5/site-packages/sklearn/base.py:311: UserWarning: Trying to unpickle estimator SVC from version 0.18.1 when using version 0.19.1. This might lead to breaking code or invalid results. Use at your own risk.
UserWarning)
Related
I'm using some code written by my lecturer & I'm running it on a GPU in Google Colab. At the beginning of the code the tf-nightly package is installed using !pip install tf-nightly. Afterwards, the following packages are imported and the version of tf used is printed out as follows:
from tensorflow import keras
from tensorflow.keras import layers
# Helper libraries
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from mpl_toolkits.axes_grid1 import make_axes_locatable
print(tf.__version__)
For some reason, sometimes the version of tf used isn't always 2.3.xxx but instead sometimes it's 2.2 - but not always. Usually this happens when the tab has been open for a while but I haven't been using it.
This then causes the error
"AttributeError: module 'tensorflow.keras.preprocessing' has no attribute 'image_dataset_from_directory'" when I try to use this package.
Can anyone tell me how to stop this from happening/what to do if it does happen?
Thank you very much in advance.
My code:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
from tensorflow.python.compiler.tensorrt import trt_convert as trt
# import tensorflow.contrib.slim as slim
When I run it, get this error:
ModuleNotFoundError: No module named 'tensorflow.python.compiler.tensorrt'
Also, instead of from tensorflow.python.compiler.tensorrt import trt_convert as trt I used from tensorflow.python.compiler.tensorrt import trt but it did not change anything.
I use TensorFlow version 1.14.
Also worth mentioning https://forums.developer.nvidia.com/t/error-converting-tensorflow-model-to-tensorrt-on-windows-10/83892 its not supported on windows 10
In version that lower then 1.14.1 the right import is:
import tensorflow.contrib.tensorrt as trt
try to change
from tensorflow.python.compiler.mlcompute import mlcompute
for setting the GPU device in Metal plugin. We honor the Tensorflow's device placement logic. So depending on the supported operations in Metal plugin the layers will be mapped to GPU by TF's device placer. You can use tf.debugging.set_log_device_placement(
True) to dump out the layers mapped to GPU. I just removed the mlcompute import below and was able to train the network.
I am getting this error after running this line of codes to import libraries for implementing a neural style algorithm:
import os
import sys
import scipy.io
import scipy.misc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from PIL import Image
from nst_utils import *
import numpy as np
import tensorflow as tf
%matplotlib inline
Do you have a copy of nst_utils.py?
It is part of the work done when going through deeplearning.ai's Deep Learning specialization online course, specifically Week 4 of Convolutional Neural Networks. You need to have a copy of nst_utils.py in the same directory as that code you're running (or that it's added to your sys.path).
If you do a search for nst_utils.py, you'll get some links to github repositories of people who went through the course, and posted their work online, like this: https://github.com/JudasDie/deeplearning.ai. You could probably copy their nst_utils.py code (check their README for usage and license notes), though it would have been better if you went through the course yourself.
I tried to follow a tutorial on how to setup tensorflow gpu (https://www.youtube.com/watch?v=tPq6NIboLSc) but on the jupyter step i am getting this error :https://pastebin.com/gm3g8cC5
(ive set in in a pastebin because its very long)
I dont know what to do, ive also tried others tutorial but none of the others works, they also got errors ( but they are differents) at the jupyter step.
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops
if StrictVersion(tf.__version__) < StrictVersion('1.12.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.12.*.')
Here is the part where the errors pops.
I dont know what is my tensorflow version since when i am trying to import it i am getting OSError: [WinError 193] %1 is not a valid Win32 application
I am creating a system in order to predict earthquakes. There's this code in which there is a line %config InlineBackend.figure_format = 'retina'.
Whenever I run my python code it gives the error as ("% invalid syntax").
Earlier I had the problem of %matplotlib statement which I figured out through google. But, this problem is sucking me.
https://www.kaggle.com/pablocastilla/predict-earthquakes-with-lstm ("The source from where the code has been taken")
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from subprocess import check_output
from keras.layers.core import Dense, Activation, Dropout
from keras.layers.recurrent import LSTM
from keras.models import Sequential
from sklearn.cross_validation import train_test_split
import time #helper libraries
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
from numpy import newaxis
from geopy.geocoders import Nominatim
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'inline')
import warnings
warnings.filterwarnings('ignore')
%config InlineBackend.figure_format = 'retina'
# Any results you write to the current directory are saved as output.
from subprocess import check_output
print(check_output(["ls", "../input"]).decode("utf8"))
So it is showing "error invalid syntax " and the % sign before the word config has been highlighted.
The expected output is that I should not recieve an error and any results that are written to the directory are given out.
That % syntax is defining a IPython Magic Command. Read: Magic commands
Give this a try
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('retina')
Taken from Configure the backend of Ipython to use retina display mode with code
You need to install Ipython library in order to do this. Also if you get "No module named ipykernel" then install ipykernel.
pip install ipython
pip install ipykernel
Edit: but I highly recommend using jupyter notebooks for example give google colab a try : https://colab.research.google.com/notebooks/welcome.ipynb
Commands starting with % are not valid python commands, they are only supported by ipython/jupyter interpreter, not by the official python interpreter.