I am trying to learn from a python script on semantic search that uses sentence transformer-BERT, While compiling this python script (semantic_search.py) file I encountered the following error:
Traceback (most recent call last):
File "semantic_search.py", line 6, in <module>
import keras.backend.tensorflow_backend as tb
ModuleNotFoundError: No module named 'keras'
Kindly suggest possible source of error and corrections.
This is a problem with versions of keras and tensorflow. It sounds like this tutorial was written before keras became a part of tensorflow. For more info on why this happened and what version you should use, see this article.
Probably what you'd need is to change any imports in the script that start with keras to tensorflow.keras, if you have tensorflow version 2.0 and above. So for that line specifically, you probably want:
import tensorflow.keras.backend as tb
Related
I am following the tutorial of driverless: Driverless AI Standalone Python Scoring Pipeline, you can check it in the following link:
http://docs.h2o.ai/driverless-ai/latest-stable/docs/userguide/scoring-standalone-python.html#tar-method-py
I am performing:
Running Python Scoring Process - Recommended
but, when running the last step:
DRIVERLESS_AI_LICENSE_KEY = "pastekey here" SCORING_PIPELINE_INSTALL_DEPENDENCIES = 0 /path/to/your/dai-env.sh ./run_example.sh
the following error happens:
Traceback (most recent call last): File "example.py", line 7, in
from scoring_h2oai_experiment_5fd7ff9c_b11a_11eb_b91f_0242ac110002 import Scorer File
"/usr/local/lib/python3.6/dist-packages/scoring_h2oai_experiment_5fd7ff9c_b11a_11eb_b91f_0242ac110002/init.py",
line 1, in
from .scorer import Scorer File "/usr/local/lib/python3.6/dist-packages/scoring_h2oai_experiment_5fd7ff9c_b11a_11eb_b91f_0242ac110002/scorer.py",
line 7, in
from h2oaicore import application_context
ModuleNotFoundError: No module named 'h2oaicore'
--
Hope you can help me, thanks in advance.
Apparently it doesn't find your h20aicore module. One brute force method to import it could be do the following in your python script:
import sys
import os
sys.path.append(os.path.abspath("path/to/module"))
or alternatively you should add it to your python path.
I agree with #BlackPhoenix's comment. It is looking for h2oaicore module. The DAI Python scoring pipeline comes with a h2oaicore .whl file. Check out the shell script, run_example.sh. It should contain steps about pip installing h2oaicore.
I am converting the T5 model from pytorch to ONNX using this script, but I am running into an Import module error. I don't think this a structural problem as this script has been used before by other people with no issues. Any ideas as to why I might be getting this error?
Here is the full error:
Traceback (most recent call last):
File "c:GitHub\models\text\machine_comprehension\t5\dependencies\T5-export.py", line 2, in <module>
from .models import CombinedDecoder, SimplifiedT5Encoder
ImportError: attempted relative import with no known parent package
I am trying to train M-RCNN using Keras and RetinaNet as in the Keras founder's example. I installed retinanet package but this module isn't found. May be it is related to that my TF doesn't use GPU? How to check that?
from keras_retinanet.utils.gpu import setup_gpu
Traceback (most recent call last):
File "<ipython-input-2-1f3ae263a7c6>", line 1, in <module>
from keras_retinanet.utils.gpu import setup_gpu
ModuleNotFoundError: No module named 'keras_retinanet.utils.gpu'
You probably need to install some submodules. The beginning of this code may help you https://www.kaggle.com/labintsevai/keras-retinanet-submission
I want to optimize my neural network (Resnet101 from Google) for inference with TensorRT (ver. 5.1). I've been looking for blogs and tutorials how to do it and found some stuff like here and a few other. All of them have one common thing:
trt_graph = trt.create_inference_graph(
getNetwork(network_file_name),
outputs,
max_batch_size=batch_size,
max_workspace_size_bytes=workspace_size,
precision_mode=”INT8")
But the problem is that my version of TensorRT does not have such function. I get an output as below.
Python 3.6.6 |Anaconda custom (64-bit)
>>> import tensorrt as trt
>>> trt.__version__
5.1.2.2
>>> trt.create_inference_graph()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorrt' has no attribute 'create_inference_graph'
Does anyone know if that function was replaced with other in version 5.1 of TensorRT? How to run it?
Some installations of tensorflow already have tensorrt by default. Try with;
import tensorflow.contrib.tensorrt as trt
This is also another location from where you can import tensorrt
from tensorflow.python.compiler.tensorrt import trt_convert as trt
As #Uziel suggested Tensorrt should be used with:
import tensorflow.contrib.tensorrt as trt
Unfortunately in my case that import caused a following error:
tensorflow.python.framework.errors_impl.NotFoundError: libnvinfer.so.4: cannot open shared object file: No such file or directory
There was a problem with my installation of TensorRT. After reinstalling everything it works now.
i have installed theano a deep neural network library and am trying to run some examples, but it looks like the script cant find some of the modules. i tried setting path
export PYTHONPATH=/Library/Python/2.7/site-packages/theano
sys.path.append('/Library/Python/2.7/site-packages/theano')
but both are not working. I get this error. I see that the modules are properly installed in subdirectory of theano /Library/Python/2.7/site-packages/theano/tensor/.. but somehow python cant seem to find the modules
Please can someone help. I am using a mac.
$python theano_mnist.py
Traceback (most recent call last):
File "theano_mnist.py", line 45, in <module>
import theano
File "/Users/prabhubalakrishnan/Desktop/theano.py", line 6, in <module>
from theano.tensor.nnet import conv
ImportError: No module named tensor.nnet
There is an issue on Theano repository. As fast solution I have:
Opened the file "miniconda3/envs/YOUR_CONDA_ENV_NAME/lib/python3.4/site-packages/theano/tensor/signal/downsample.py"
change the import import pool in from . import pool
and it works!