I am learning machine learning and trying to create a one output from 3 input single layer from Kaggle, I am trying to import tensor flow and keras with the following code:
from tensorflow import keras
from tensorflow.keras import layers
# Create a networkth 1 linear unit
model = keras.Sequential([
layers.Dense(unit =1, input_shape=[3])
])
but I get the following error:
"/Users/ahmedhamadto/PycharmProjects/Deep Learning/venv/bin/python" "/Users/ahmedhamadto/PycharmProjects/Deep Learning/main.py"
Traceback (most recent call last):
File "/Users/ahmedhamadto/PycharmProjects/Deep Learning/main.py", line 1, in <module>
from tensorflow import keras
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/__init__.py", line 37, in <module>
from tensorflow.python.eager import context
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/eager/context.py", line 29, in <module>
from tensorflow.core.framework import function_pb2
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/core/framework/function_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/google/protobuf/pyext/_message.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (__ZNK6google8protobuf10TextFormat21FastFieldValuePrinter19PrintMessageContentERKNS0_7MessageEiibPNS1_17BaseTextGeneratorE)
Process finished with exit code 1
I am using a M1 Pro MacBook Pro incase the info is relevant.
Related
I'm trying to make tf lite work but it has some import problem
as I type :
Import tflite_model_maker to python
It throws these errors:
/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/read_weights.py:28: FutureWarning: In the future np.objectwill be defined as the corresponding NumPy scalar. np.uint8, np.uint16, np.object, np.bool] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/miscope/examples/tensorflow_examples/lite/model_maker/pip_package/src/tflite_model_maker/__init__.py", line 44, in <module> from tflite_model_maker import audio_classifier File "/home/miscope/examples/tensorflow_examples/lite/model_maker/pip_package/src/tflite_model_maker/audio_classifier/__init__.py", line 24, in <module> from tensorflow_examples.lite.model_maker.core.data_util.audio_dataloader import DataLoader File "/home/miscope/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/data_util/audio_dataloader.py", line 27, in <module> from tensorflow_examples.lite.model_maker.core.task.model_spec import audio_spec File "/home/miscope/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/task/model_spec/__init__.py", line 20, in <module> from tensorflow_examples.lite.model_maker.core.task.model_spec import audio_spec File "/home/miscope/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py", line 30, in <module> from tensorflow_examples.lite.model_maker.core.task import model_util File "/home/miscope/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/task/model_util.py", line 28, in <module> from tensorflowjs.converters import converter as tfjs_converter File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/__init__.py", line 21, in <module> from tensorflowjs import converters File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/converters/__init__.py", line 21, in <module> from tensorflowjs.converters.converter import convert File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/converters/converter.py", line 35, in <module> from tensorflowjs.converters import keras_h5_conversion as conversion File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/converters/keras_h5_conversion.py", line 33, in <module> from tensorflowjs import write_weights # pylint: disable=import-error File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/write_weights.py", line 25, in <module> from tensorflowjs import read_weights File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/tensorflowjs/read_weights.py", line 28, in <module> np.uint8, np.uint16, np.object, np.bool] File "/home/miscope/miniconda3/envs/sencondenv/lib/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'object'.np.objectwas a deprecated alias for the builtinobject. To avoid this error in existing code, use object by itself. Doing this will not modify any behavior and is safe. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
I think I installed all the required package
with the setup.py
from this repo (pip_packages) https://github.com/tensorflow/examples/tree/master/tensorflow_examples/lite/model_maker
I'm using miniconda with python3.9.2
I don't even know if I can use tf lite model maker outside of google colab.
I would like to train a custom object detection model like this but outside of colab.
https://colab.research.google.com/github/khanhlvg/tflite_raspberry_pi/blob/main/object_detection/Train_custom_model_tutorial.ipynb
I hope you can help, thanks.
I'm doing a school project, and decided to work on an idea of using a django website to display a chatbot's response. The website should also allow users to add an intent for the chatbot to learn from. After working on the website, I tried importing Keras to begin writing the training file.
import random
import json
import pickle
import numpy as np
import nltk
from nltk.stem import WordNetLemmatizer
from keras.models import Sequential
from keras.layers import Dense, Activation, Dropout
from keras.optimizers import SGD
# Rest of the code isn't necessary as error is raised above
However, when I ran the file, it keeps giving me the following error:
Traceback (most recent call last):
File "D:\User\SILPythonChatbot\SILProject\BotApp\training.py", line 9, in <module>
from keras.models import Sequential
File "D:\User\SILPythonChatbot\venv\lib\site-packages\keras\__init__.py", line 21, in <module>
from keras import models
File "D:\User\SILPythonChatbot\venv\lib\site-packages\keras\models\__init__.py", line 18, in <module>
from keras.engine.functional import Functional
File "D:\User\SILPythonChatbot\venv\lib\site-packages\keras\engine\functional.py", line 24, in <module>
import tensorflow.compat.v2 as tf
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\__init__.py", line 42, in <module>
from tensorflow.python import data
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\__init__.py", line 21, in <module>
from tensorflow.python.data import experimental
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\experimental\__init__.py", line 96, in <module>
from tensorflow.python.data.experimental import service
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\experimental\service\__init__.py", line 419, in <module>
from tensorflow.python.data.experimental.ops.data_service_ops import distribute
File "D:\UserSILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py", line 22, in <module>
from tensorflow.python.data.experimental.ops import compression_ops
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py", line 16, in <module>
from tensorflow.python.data.util import structure
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\util\structure.py", line 22, in <module>
from tensorflow.python.data.util import nest
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\data\util\nest.py", line 34, in <module>
from tensorflow.python.framework import sparse_tensor as _sparse_tensor
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\framework\sparse_tensor.py", line 24, in <module>
from tensorflow.python.framework import constant_op
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\framework\constant_op.py", line 25, in <module>
from tensorflow.python.eager import execute
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\eager\execute.py", line 22, in <module>
from tensorflow.python.framework import ops
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 49, in <module>
from tensorflow.python.framework import cpp_shape_inference_pb2
File "D:\User\SILPythonChatbot\venv\lib\site-packages\tensorflow\python\framework\cpp_shape_inference_pb2.py", line 203, in <module>
'HandleShapeAndType' : _reflection.GeneratedProtocolMessageType('HandleShapeAndType', (_message.Message,), {
TypeError: 'DTypeMeta' object is not iterable
I tried reinstalling. However, that failed as well.
Does anybody know why this happens, or how to fix it? Thanks.
I am trying to create my own PyEnvironment for TF-Agents.
However, this error keeps showing up:
AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
I have found out that this seems to be an issue with tensorflow-probability, but I have installed the version tensorflow-probability=0.7.0 recommended at
https://github.com/tensorflow/agents/issues/91
I have tried reinstalling and updating
tensorflow-gpu=2.0.0-beta1
tf-agents-nightly
tensorflow-probability=0.7.0
Here is a minimal code example:
from tf_agents.environments import py_environment
class myEnv(py_environment.PyEnvironment):
def __init__(self):
pass
def _reset(self):
pass
def _step(self, action):
pass
This is the full error message when running this minimum example:
Traceback (most recent call last): File ".\env_mwe.py", line 1, in <module>
from tf_agents.environments import py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\__init__.py", line 18, in <module>
from tf_agents.environments import batched_py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\batched_py_environment.py", line 33, in <module>
from tf_agents.environments import py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\py_environment.py", line 29, in <module>
from tf_agents.trajectories import time_step as ts File "C:\Python37\lib\site-packages\tf_agents\trajectories\__init__.py", line 19, in <module>
from tf_agents.trajectories import time_step File "C:\Python37\lib\site-packages\tf_agents\trajectories\time_step.py", line 28, in <module>
from tf_agents.specs import array_spec File "C:\Python37\lib\site-packages\tf_agents\specs\__init__.py", line 20, in <module>
from tf_agents.specs.distribution_spec import DistributionSpec File "C:\Python37\lib\site-packages\tf_agents\specs\distribution_spec.py", line 22, in <module>
import tensorflow_probability as tfp File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\__init__.py", line 78, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\__init__.py", line 22, in <module>
from tensorflow_probability.python import distributions File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\__init__.py", line 64, in <module>
from tensorflow_probability.python.distributions.linear_gaussian_ssm import LinearGaussianStateSpaceModel File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\linear_gaussian_ssm.py", line 41, in <module>
_matmul = linear_operator_util.matmul_with_broadcast AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
Found it!
In order to use tensorflow-gpu with tensorflow-probability, one needs to install tfp-nightly
So pip3 install --upgrade tfp-nightly did the trick
To use 2.0.0beta1 requires tfp-nightly.
I have been trying to import theano.tensor in my code.
I have used theano.tensor before. All of my previous code importing theano.tensor works perfectly in my machine. Now I am trying to write another script importing the tensor from theano and I am getting the following exception.
Traceback (most recent call last):
File "code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/__init__.py", line 52, in <module>
from theano.gof import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/__init__.py", line 56, in <module>
from theano.gof.opt import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/opt.py", line 11, in <module>
import pdb
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
File "/localtmp/saikat/CovInfo/Closure/code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/__init__.py", line 6, in <module>
from theano.tensor.basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/basic.py", line 17, in <module>
from theano.tensor import elemwise
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/elemwise.py", line 13, in <module>
from theano import scalar
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/__init__.py", line 2, in <module>
from .basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/basic.py", line 25, in <module>
from theano import gof, printing
File "/anaconda3/lib/python3.5/site-packages/theano/printing.py", line 22, in <module>
from theano.compile import Function, debugmode, SharedVariable
File "/anaconda3/lib/python3.5/site-packages/theano/compile/__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py", line 22, in <module>
import theano.compile.mode
File "/anaconda3/lib/python3.5/site-packages/theano/compile/mode.py", line 77, in <module>
OPT_NONE = gof.Query(include=[], exclude=exclude)
AttributeError: module 'theano.gof' has no attribute 'Query'
I cannot find any plausible reason for this exception.
I guess i got your problem. See in the error log:
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
I believe there is another script called code.py in Theano which gets called from pdb.py when python interpreter executes your script which is also named as code.py. I am guessing python interpreter is mixing up these two scripts and executing the wrong one! You can change the filename and check whether the error disappear or not.
Greeting Dear Community,
I try to use the python keras package and I got this error:
I am running this on a oracle-linux virtual box. Is it something to do
it expects some kind of GPU box ?
Thx for the help.
In [59]: from keras.models import Sequential#issue
...:
Traceback (most recent call last):
File "<ipython-input-59-0f55ca179bba>", line 1, in <module>
from keras.models import Sequential#issue
File "/home/oracle/anaconda/lib/python2.7/site-packages/keras/models.py", line 15, in <module>
from .utils.layer_utils import container_from_config
File "/home/oracle/anaconda/lib/python2.7/site-packages/keras/utils/layer_utils.py", line 10, in <module>
from ..layers.convolutional import Convolution1D, Convolution2D, MaxPooling1D, MaxPooling2D, ZeroPadding2D
File "/home/oracle/anaconda/lib/python2.7/site-packages/keras/layers/convolutional.py", line 6, in <module>
from theano.sandbox.cuda import dnn
File "/home/oracle/anaconda/lib/python2.7/site-packages/theano/sandbox/cuda/dnn.py", line 9, in <module>
from theano.gof import Optimizer, local_optimizer, COp
ImportError: cannot import name COp
The line from dnn.py
from theano.gof import Optimizer, local_optimizer, COp