簡體   English   中英

如何解決這個 AttributeError: module 'tensorflow' has no attribute 'get_default_graph'?

[英]How to fix this AttributeError: module 'tensorflow' has no attribute 'get_default_graph'?

我的 tensorflow 版本=2.0.0,keras 版本=2.1.5,python 版本=3.7

代碼:

import os
import cv2
import numpy as np
import argparse
import json
       
from PIL import Image
from mtcnn import MTCNN
detector = MTCNN()

返回一個錯誤,如下所示:

AttributeError: module 'tensorflow' has no attribute 'get_default_graph'

許多較新版本的 Tensorflow 都存在不一致之處。

嘗試降級您的 tensorflow 版本pip install tensorflow==1.13.1

或將您的 Keras 升級到 2.3 或更高版本pip install -U keras

如果你很勇敢,你也可以去挖掘哪個 python 文件有一行像import keras.something.something並將其更改為import tensorflow.keras.something

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM