colab导入自己写的包

需求:导入自己写的.py文件里的类(不知道怎么定义)

from .py import class

实现:

1上传.py文件到谷歌云

2切换文件所在路径(path)

3正常导入即可

导入attention_keras.py文件

报错No module named 'keras.engine.topology'

解决https://stackoverflow.com/questions/68862735/keras-vggface-no-module-named-keras-engine-topology

I solved this issue in Google Colab by changing the import from

from keras.engine.topology import get_source_inputs

to

from keras.utils.layer_utils import get_source_inputs

新问题

ImportError: cannot import name 'Layer' from 'keras.utils.layer_utils' (/usr/local/lib/python3.8/dist-packages/keras/utils/layer_utils.py)

返回旧问题

新解https://blog.csdn.net/dpengwang/article/details/126330500

解决

你可能感兴趣的:(tensorflow,深度学习,人工智能)