Error to import Network from keras.engine.topolgy - keras

I installed the topology package by downgrading the keras (pip install 'keras==2.1.6' --force-reinstall), because it doesn't exist in newer versions. I am still getting an error to import Network.
Trying:
from keras.engine.topology import Network
Error:
ImportError: cannot import name 'Network' from 'keras.engine.topology' (/usr/local/lib/python3.7/dist-packages/keras/engine/topology.py)
If Network doesn't exist then how can I get this so that rest of the code (CycleGAN) can use Network(). Any help would be appreciated.

Related

Tensorflow federated can't be imported on google collabs notebook

I wrote following codes on a new google collabs notebook:
!pip install --quiet --upgrade tensorflow-federated-nightly
import tensorflow as tf
import tensorflow_federated as tff
And I got these error messages while importing tensorflow_federeated:
/usr/local/lib/python3.7/dist-packages/keras/api/_v1/keras/experimental/__init__.py in <module>()
8 from keras.feature_column.sequence_feature_column import SequenceFeatures
9 from keras.layers.rnn.lstm_v1 import PeepholeLSTMCell
---> 10 from keras.optimizers.learning_rate_schedule import CosineDecay
11 from keras.optimizers.learning_rate_schedule import CosineDecayRestarts
12 from keras.premade_models.linear import LinearModel
ModuleNotFoundError: No module named 'keras.optimizers.learning_rate_schedule'; 'keras.optimizers' is not a package
These errors seem to be spawning from the modules installed on the colabs itself, instead of my code.
Any idea on what can be done to fix this?
Collab Defaults to 3.7 according to a similar problem But although the solution to upgrade to 3.9 did indeed upgrade to python 3.9, TFF still didn't work for me, even when I installed locally. So, find a different path.

ImportError: cannot import name 'maybe_sync' from 'fsspec.asyn'

I am getting the following error while using simpletransformer library on Saturn cloud.
from simpletransformers.classification import ClassificationModel
ImportError: cannot import name 'maybe_sync' from 'fsspec.asyn' (/srv/conda/envs/saturn/lib/python3.7/site-packages/fsspec/asyn.py)
I am not getting this error while using Google Colab.
I tried to install older versions of s3fs==0.5.1 and fsspec==0.8.4 but it's not working.

dispatcher not defined when importing module

I was attempting to import some modules in a Spyder IDE:
from sklearn.neighbors import KNeighborsClassifier
from mlxtend.feature_selection import ExhaustiveFeatureSelector
For both of the import statements above I get the error:
"NameError: name 'dispatcher' is not defined"
Tried install package "dispatcher"
I had the same error, but while using pandas.DataFrame.sample. I managed to track the error to numpy.random.choice, I was using version 1.15. I updated numpy to version 1.17.3 and the issue was solved. If you are using conda, you can do so by typing
conda update numpy=1.17.3
on the Anaconda prompt.

ImportError: cannot import name '_print_elapsed_time'

Hi so I'm trying to use the make_pipeline module in sklearn. But when I try to import it with:
from sklearn.pipeline import make_pipeline
I get this error:
ImportError: cannot import name '_print_elapsed_time'
I've googled it but there seems to be no other posts about this. I tried reinstalling scikitlearn but I still get the same error :/ Anyone have any ideas?
It looks like this was a bug introduced into one of the newer versions of scikit-learn (I got this same issue in version 0.21.2).
I was able to fix this by downgrading to scikit-learn version 0.20.0
>> pip install scikit-learn==0.20.0

cannot import name 'convert_saved_model'

I am trying to convert a frozen grap to tflite using convert_saved_model in tensorflow, but i am getting the following error
from tensorflow.contrib.lite.python import convert_saved_model
ImportError: cannot import name 'convert_saved_model'
Here's the code i've been using
from tensorflow.contrib.lite.python import convert_saved_model
convert_saved_model.tflite_from_saved_model(saved_model_dir="optimized_graph.pb",
output_file="/tflite_Model")
I am using a Windows 8.1 and tensorflow 1.8.
I've tried using toco_convert but got the error
module tensorflow.contrib has no attribute 'lite'
Please try with Tensorflow 1.9 and file a Github issue if this is still not working https://github.com/tensorflow/tensorflow/issues

Resources