problems about importing caffe - python

when I import caffe,it got some errors:
import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lili/caffe/1master/caffe-master/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/lili/caffe/1master/caffe-master/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/lili/caffe/1master/caffe-master/python/caffe/io.py", line 8, in <module>
from caffe.proto import caffe_pb2
File "/home/lili/caffe/1master/caffe-master/python/caffe/proto/caffe_pb2.py", line 23, in <module>
\x06\x66iller\x18\x01 \x01(\x0b\x32\x16.caffe.FillerParameter\x12\x1d\n\x0e\x63hannel_shared\x18\x02 \x01(\x08:\x05\x66\x61lse*\x1c\n\x05Phase\x12\t\n\x05TRAIN\x10\x00\x12\x08\n\x04TEST\x10\x01')
TypeError: __init__() got an unexpected keyword argument 'syntax
who can help me?

Looks like there is some problem with the model prototype or the solver prototype you are using for training. Please make sure that the prototype files have only the defined attributes.

check your version of protobuf, it seems the version of protoc and python protobuf do not match

Related

Tflite model m aker issue - undefined symbol table __scann_ops.os

Anyone know how to solve this python tensorflow issue?
Traceback (most recent call last):
File "lite_model_gen.py", line 6, in <module>
from tflite_model_maker.config import ExportFormat
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tflite_model_maker/__init__.py", line 51, in <module>
from tflite_model_maker import searcher
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tflite_model_maker/searcher/__init__.py", line 25, in <module>
from tensorflow_examples.lite.model_maker.core.task.searcher import ExportFormat
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/task/searcher.py", line 30, in <module>
from tensorflow_examples.lite.model_maker.core.utils import ondevice_scann_builder
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/utils/ondevice_scann_builder.py", line 17, in <module>
from scann.proto import scann_pb2
File "/home/ubuntu/bert_QA/env/lib/python3.8/site-packages/scann/__init__.py", line 2, in <module>
from scann.scann_ops.py import scann_ops
File "/home/ubuntu/bert_QA/env/lib/python3.8/site-packages/scann/scann_ops/py/scann_ops.py", line 23, in <module>
_scann_ops_so = tf.load_op_library(
File "/home/ubuntu/bert_QA/env/lib/python3.8/site-packages/tensorflow/python/framework/load_library.py", line 54, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/ubuntu/bert_QA/env/lib/python3.8/site-packages/scann/scann_ops/cc/_scann_ops.so: undefined symbol: _ZN4absl12lts_2021032416numbers_internal9kHexTableE
It occurs when I attempt to use the tflite_model_maker library. Corrupted or outdated shared library file?
Okay, I discovered it could be fixed by simply installing scann using pip:
pip install scann

Error after updating scikit-learn to version 0.20.1 : cannot import name 'Empty' from 'queue'

I upgraded scikit-learn to version 0.20.1 using anaconda3 after getting an error message concerning balanced_accuracy_score from metrics in scikit-learn. This is apparently not available in version 0.19.
After this upgrade i get the following error:
Traceback (most recent call last):
File "test4.py", line 4, in <module>
from sklearn import metrics
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\__init__.py", line 6
4, in <module>
from .base import clone
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\base.py", line 13, i
n <module>
from .utils.fixes import signature
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\utils\__init__.py",
line 14, in <module>
from . import _joblib
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\utils\_joblib.py", l
ine 22, in <module>
from ..externals import joblib
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\__i
nit__.py", line 119, in <module>
from .parallel import Parallel
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\par
allel.py", line 28, in <module>
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\_pa
rallel_backends.py", line 22, in <module>
from .executor import get_memmapping_executor
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\exe
cutor.py", line 14, in <module>
from .externals.loky.reusable_executor import get_reusable_executor
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\ext
ernals\loky\__init__.py", line 13, in <module>
from .reusable_executor import get_reusable_executor
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\ext
ernals\loky\reusable_executor.py", line 11, in <module>
from .process_executor import ProcessPoolExecutor, EXTRA_QUEUED_CALLS
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\ext
ernals\loky\process_executor.py", line 82, in <module>
from .backend.queues import Queue, SimpleQueue, Full
File "C:\Users\Pieter\Anaconda3\lib\site-packages\sklearn\externals\joblib\ext
ernals\loky\backend\queues.py", line 21, in <module>
from multiprocessing.queues import Full
File "C:\Users\Pieter\Anaconda3\lib\multiprocessing\queues.py", line 20, in <m
odule>
from queue import Empty, Full
ImportError: cannot import name 'Empty' from 'queue' (C:\Users\Pieter\Python pro
gs\queue.py)
Are you running this program from "C:\Users\Pieter\Python progs"?
Looks like you have a file named queue.py in "C:\Users\Pieter\Python pro
gs\" which is shadowing the actual module queue in multiprocessing lib. And hence the error.
There are two possible reasons for this:
Maybe this line:
from queue import Empty, Full
has been added in new version, so earlier it did not error even when your custom made queue.py was present.
Maybe you have created your queue.py recently after updating the scikit-learn and the above line was always present. In this case, error should occur on both versions.
Rename your program from queue.py and auto-compiled queue.pyc
to something else and it should work.

theano and scikit-neuralnetwork testing error

When I using "python examples/plot_mlp.py --parama activation", the error is happend. Please help me to fix it.(Ubuntu 16.04/ python 2.7.12/ theano 1.0.2/ sklearn 0.19.1)
/usr/local/lib/python2.7/dist-packages/sklearn/cross_validation.py:41:
DeprecationWarning: This module was deprecated in version 0.18 in favor of
the model_selection module into which all the refactored classes and
functions are moved. Also note that the interface of the new CV iterators
are different from that of this module. This module will be removed in
0.20."This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "examples/plot_mlp.py", line 30, in <module>
from sknn import mlp
File "/home/admin/scikit-neuralnetwork/sknn/mlp.py", line 18, in
<module>
import theano
File "/usr/local/lib/python2.7/dist-packages/theano/__init__.py", line
88, in <module>
from theano.configdefaults import config
File "/usr/local/lib/python2.7/dist-packages/theano/configdefaults.py",
line 47, in <module>
in_c_key=True
File "/usr/local/lib/python2.7/dist-packages/theano/configparser.py",
line 281, in AddConfigVar
configparam.fullname)
AttributeError: ('This name is already taken', 'floatX')

pong from pixle with CNN and policy gradient

i get a stuck at this point , i've readed "pong from pixel" of kapathy blog, and i wanna improve this by integrate CNN model then i've got this tutor from GG.
**link here:
https://github.com/yshvrdhn/Pong-Agent-Using-Policy-Gradients/blob/master/pong_keras.py
But i cannot run and dont know the usage of this line:
model= learning_model() ,plz someone can help me ???
***error that i got after compile these code :
Traceback (most recent call last):
File "C:\Users\thinh dang\Desktop\pong\kerasDemo.py", line 3, in <module>
from keras.models import Sequential
File "C:\Python27\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Python27\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Python27\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Python27\lib\site-packages\keras\backend\__init__.py", line 84, in <module>
from .theano_backend import *
File "C:\Python27\lib\site-packages\keras\backend\theano_backend.py", line 7, in <module>
import theano
File "C:\Python27\lib\site-packages\theano\__init__.py", line 110, in <module>
from theano.compile import (
File "C:\Python27\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
from theano.compile.mode import *
File "C:\Python27\lib\site-packages\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "C:\Python27\lib\site-packages\theano\gof\vm.py", line 674, in <module>
from . import lazylinker_c
File "C:\Python27\lib\site-packages\theano\gof\lazylinker_c.py", line 140, in <module>
preargs=args)
File "C:\Python27\lib\site-packages\theano\gof\cmodule.py", line 2388, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): The system cannot find the path specified.
It looks like you don't have theano installed. You can do so with:
pip install theano
As a side advice, I would also recommend virtual environments, so it will be easier to keep your projects isolated.
I would recommend working with Anaconda.

Error after "from new import instancemethod" when importing scipy.stats

I am getting an exception from scipy whenever I try to import the nltk package. The command and the error looks like this:
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/usr/local/lib/python2.7/dist-packages/nltk/collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "/usr/local/lib/python2.7/dist-packages/nltk/metrics/__init__.py", line 16, in <module>
from nltk.metrics.scores import (accuracy, precision, recall, f_measure,
File "/usr/local/lib/python2.7/dist-packages/nltk/metrics/scores.py", line 16, in <module>
from scipy.stats.stats import betai
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/__init__.py", line 344, in <module>
from .stats import *
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/stats.py", line 176, in <module>
from . import distributions
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 10, in <module>
from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/_distn_infrastructure.py", line 43, in <module>
from new import instancemethod
File "new.py", line 107
return copy.deepcopy(self)
^
IndentationError: expected an indented block
I executed this command in a terminal (ubuntu 16.04 LTS system). I did not find anything about this error and the indentation doesn't look wrong.
The SyntaxError is in your file new.py (I guess it's in your current working directory). Try to switch to a directory where no new.py file is present (or move the new.py file in another directory), then the internal scipy import should work without problems.
On the other hand you can just upgrade to scipy 0.19.x. They removed the import there and it should work without problems.
Note that it's always a bad idea to name python files like builtin-modules! That's a common source for exceptions or unexpected behaviour.

Categories