简体   繁体   中英

AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike'

I installed tensorflow 2.3.1 and keras 2.4.0 versions: here is my code;

from keras.models import Sequential from keras.layers import Conv2D, ZeroPadding2D, Activation, Input, concatenate from keras.models import Model from keras.layers.normalization import BatchNormalization

from keras.layers.pooling import MaxPooling2D, AveragePooling2D from keras.layers.merge import Concatenate from keras.layers.core import Lambda, Flatten, Dense from keras.initializers import glorot_uniform

from keras.engine.topology import Layer from keras import backend as K K.set_image_data_format('channels_first') import cv2 import os import numpy as np from numpy import genfromtxt import pandas as pd

import tensorflow as from fr_utils import * from inception_blocks import *

import matplotlib.pyplot as plt import face_recognition from PIL import Image import sys from tensorflow.python.framework import ops ops.reset_default_graph() np.set_printoptions(threshold=sys.maxsize)

then I wrote;

FRmodel=faceRecoModel(input_shape=(3,96,96)) FRmodel.summary()

THEN IT GIVES ERROR: https://i.stack.imgur.com/myjsO.png

For me, this was the fix

from tensorflow.keras.models import Sequential from keras.layers import Conv2D, ZeroPadding2D, Activation, Input, concatenate

from tensorflow.keras.models import Model

from tensorflow.keras.layers.normalization import BatchNormalization

from tensorflow.keras.layers.pooling import MaxPooling2D, AveragePooling2D

from tensorflow.keras.layers.merge import Concatenate

from tensorflow.keras.layers.core import Lambda, Flatten, Dense

from tensorflow.keras.initializers import glorot_uniform

from tensorflow.keras.engine.topology import Layer

from tensorflow.keras import backend as K K.set_image_data_format('channels_first')

Another solution could be to try reinstalling Keras and Tensorflow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM