hi! I encountered a problem while using models from keras , but I got the errors - keras

from keras import models
my_mnist_model = models.load_model(modelpath)
error:
No module named 'keras.utils.generic_utils'
I've tried installing keras==2.2.4
but it still didn't work

Related

Not able to use SMOTETomek or SMOTEENN - Import Module error

I am trying to import the following libraries:
from imblearn.combine import SMOTEENN
from imblearn.combine import SMOTETomek
Unfortunately I am getting an error that says:
ModuleNotFoundError: No module named 'scipy.special.cython_special'
I have also checked on the following link :https://imbalanced-learn.org/stable/install.html and looks like almost every dependency is installed in my environment.
I am also getting the same error while I am importing Random forest classifier
from sklearn.ensemble import RandomForestClassifier
What could be the issue here?

Pytorch/Ktrain import name BartForConditionalGeneration from transformers error?

I am trying to use the package ktrain's text function
text.TransformerSummarizer()
However, when I try to use it I get the error that
TransformerSummarizer() requires PyTorch to be installed.
I installed PyTorch using different variations of conda and pip, as well as the command given on the pytorch website. After it installs and I try to use it I get:
from ktrain import text
import torch
from transformers import BartForConditionalGeneration
ts = text.TransformerSummarizer()
ImportError: cannot import name 'BartForConditionalGeneration' from 'transformers' (C:\Users\user\AppData\Roaming\Python\Python37\site-packages\transformers\__init__.py)
Any suggestions of how to fix this? Thank you!

python3 keras import error with both tensorflow and theano

With python3 (version 3.6.8) and keras
the simple script:
import keras
gives an error:
Using TensorFlow backend.
Ungültiger Maschinenbefehl (Speicherabzug geschrieben)
(in english it would be something like: "invalid machine command (memory image written)")
So I tried to use theano instead:
import os
os.environ['KERAS_BACKEND'] = 'theano'
from keras import backend as K
With python3 it shows this output:
Using Theano backend.
Ungültiger Maschinenbefehl (Speicherabzug geschrieben)
How could I get further information about the problem?
Try
from tensorflow import keras
If the problem persists, try going through the documentation on how to install and how to use it.
Keras - Tensorflow
Keras Overview - Tensorflow
Keras.io

AttributeError: module 'tensorflow' has no attribute 'get_default_graph'. I am getting this error when adding a new layer to a model

ml = Sequential()
ml.add(LSTM(64,dropout=0.5, recurrent_dropout=0.5,return_sequences=True))
This is giving me a error: AttributeError: module 'tensorflow' has no attribute 'get_default_graph'.
ml is the name of the model. I am unable to add any layers to a model. Please help.
The dependencies that I am using are:
Tensorflow: 2.0.0-beta1
Keras: 2.2.4
Python: 3.7.3
Upgrade to latest Tensorflow version instead of Beta Version.And use the import functions as mentioned below.
To install:
pip install tensorflow==2.2.0
#OR
pip install --upgrade tensorflow
Importing:
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM
ml = Sequential()
ml.add(LSTM(64,dropout=0.5, recurrent_dropout=0.5,return_sequences=True))
Your code should work fine now.

How to use densenet in Keras

I notice densenet has been added to keras (https://github.com/keras-team/keras/tree/master/keras/applications)and I want to apply it in my project but when I tried to import it in jupyter anaconda, I got an error saying:
module 'keras.applications' has no attribute 'densenet'
it seems like densenet has not been incorporated into current version of keras.
Any idea how can I add it myself?
Densenet was added in keras version 2.1.3. What version of keras are you running?
Have you tried to update keras with pip install keras --upgrade since January?

Resources