Long story short I have this problem where when I run the code it says that the module I use Tensorflow has no attribute 'merge_summary' The thing is that I don't even use merge_summary.
I have tried to uninstall tenserflow and it didn't work.
import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()
import numpy
import tflearn
import tensorflow
import json
import random
with open("intents.json") as file:
data = json.load(file)
print(data)
This should put a lot of text in the console.
You can also try tf.compat.v1.summary.merge_all as merge_summary is deprecated.
merge_summary is deprecated.
use instead :
tf.summary.merge
Related
I have been trying to import statmodels (https://www.statsmodels.org/devel/examples/notebooks/generated/ordinal_regression.html#Probit-ordinal-regression:) to google colab without success.
I tried pip install statmodels which worked but then when I tried to import the ordinal model following the code from the above website:
import numpy as np
import pandas as pd
import scipy.stats as stats
from statsmodels.miscmodels.ordinal_model import OrderedModel
The following error message came up:
ModuleNotFoundError: No module named 'statsmodels.miscmodels.ordinal_model'
I have tried to follow the instruction from https://www.statsmodels.org/devel/install.html but I am not sure what went wrong, please help, thank you so much
The module location has changed to from statsmodels.discrete.discrete_model import OrderedModel
I use virtualenv in Python. I use gensim in a script. I get this error
name 'gensim' is not defined
I tried to install genism using pip and conda. I ended up updating conda packages after some suggested solution .
I see there is genism 3.8 after reunnig pip list, but I still have the error !. Could you please tell me what to do
P.S. I take input from a html form in a Flask function. Inside the function, I call the script that has genism. The program show the forms input buttons . After clicking the submit buton, I get the error message.
import re
import numpy as np
import pandas as pd
from pprint import pprint
#database
import db
from db import *
# Gensim
import gensim
import gensim.corpora as corpora
from gensim.utils import simple_preprocess
from gensim.models import CoherenceModel
from gensim.parsing.preprocessing import preprocess_string, strip_punctuation, strip_numeric
# spacy for lemmatization
import spacy
# Plotting tools
import pyLDAvis
import pyLDAvis.gensim # don't skip this
import matplotlib.pyplot as plt
#matplotlib inline
from conn import *
from functions import *
# Enable logging for gensim - optional
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.ERROR)
import warnings
warnings.filterwarnings("ignore",category=DeprecationWarning)
Thanks in advance
I'm trying to detect objects using Yolo-v3 referring this tutorial. I have already installed darknet.
When I tried to run the following code:
from darknet import Darknet
it says:
ImportError: cannot import name 'Darknet' from 'darknet' (unknown location)
so I tried:
import darknet as dn
net = dn.load_net("cfg/tiny-yolo.cfg", "tiny-yolo.weights", 0)
then it says:
"AttributeError: module 'darknet' has no attribute 'load_net'"
How I can avoid these errors?
Use it like this.
import cv2
import matplotlib.pyplot as plt
from utils import *
from darknet import Darknet
net = Darknet("cfg/tiny-yolo.cfg")
net.load_weights("tiny-yolo.weights")
I cant seem to import identity_block and conv_block from the resnet architecture.
https://github.com/keras-team/keras-applications/blob/master/keras_applications/resnet50.py
from keras.applications.resnet50 import ResNet50,decode_predictions,identity_block, conv_block
It"s resulting in an import error.
from keras.applications.resnet50 import ResNet50,decode_predictions,identity_block, conv_block
ImportError: cannot import name 'identity_block'
You can use the following code, it is inside resnet50.
from keras.applications.resnet50 import ResNet50,decode_predictions,resnet50
identity_block, conv_block = resnet50.identity_block, resnet50.conv_block
I got the following error
ImportError: cannot import name 'resnet50' from 'keras.applications.resnet50' (/home/mike/miniconda3/lib/python3.7/site-packages/keras/applications/resnet50.py)
The official Keras library has a big change and can not be called directly by the client script in the case you mentioned. I have met the same issue and solved it as follows.
1. Download keras.applications and put keras_applications into the current directory
It is called as a library by the client script.
2. Make an independent script of resnet50_custom.py
change the original import statment
from keras.applications.imagenet_utils import _obtain_input_shape
to the new statements as follows
from keras_applications.imagenet_utils import _obtain_input_shape
3. Add the following import statement into the client script.
from resnet50_custom import identity_block, conv_block
4. Change "include_top=include_top" to "require_flatten=include_top"
input_shape = _obtain_input_shape(input_shape,default_size=224, \
min_size=197, data_format=None, require_flatten=include_top)
Cheers.
I'm trying to get the TensorFlow Object Detection API on Windows. I use Python 3.6.5 (64bits).
After running the following program:
Here is the part of the code which generates the warning:
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
import cv2
cap = cv2.VideoCapture("video.mp4")
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
I have this warning message :
Warning (from warnings module):
File "C:\Users\leahj\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\utils\visualization_utils.py", line 25
import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statements
UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
Can anybody help me please ?
The line import matplotlib; matplotlib.use('Agg') is hardcoded in object_detection\utils\visualization_utils. I don't know the reason for this; usually a package should allow the user to choose the backend.
Unless there is any other problem arising from the use of object_detection the easiest is probably to live with this warning.