python - AttributeError: module 'tensorflow' has no attribute 'name_scope'
问题描述
I ran this program just a min ago and it worked how it should. Now it returns this error and I have no clue what caused it. Here's my code:
import csv
import numpy as np
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Dense, Flatten, Activation
from keras.layers import Dropout
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from tensorflow.keras import utils
train_imgs=[]
a=[]
b=[]
with open('train.csv', 'r') as csv_file:
csv_reader=csv.reader(csv_file)
next(csv_reader)
for line in csv_reader:
for i in line[0]:
i=int(i)
a.append(i)
train_labels=utils.to_categorical(a, 10)
class_names = ["Злость", "Отвращение", "Страх", "Радость", "Грусть", "Удивление", "Нейтральная эмоция"]
And here's the error:AttributeError: module 'tensorflow' has no attribute 'name_scope'
As u see I didn't use tensorflow in this particular part of the code, same thing with name_scope. Also when I removed the import of keras and its modules, I didn't get this error, but I need keras so problem isn't solved. Does anybody know how to fix it?
解决方案
好的,所以我尝试了这个,它确实有效
pip install --ignore-installed --upgrade tensorflow==1.14.0
推荐阅读
- c# - 删除所有本地化文件并更改标准语言 c#
- python - 如何从父子目录导入模块
- c# - 如何从 MainWindows.xaml.cs 中的 ViewModel 使用 ObservableCollection
- html - 如何在 IE 中打印页面,带有背景颜色的边缘
- sql - sql server 将表示日期时间的字符串转换为日期
- laravel - Laravel 5.8 从两个不同的表中显示、更新、删除记录
- amazon-web-services - APIgateway + Lamba 测试有效,但部署的 API 导致 Lambda 超时
- c++ - 我怎样才能简化这个程序(字谜)?
- sql - 如何根据具有最大值的列过滤行?
- java - 嵌套的自动装配字段在 JUNIT 测试中保持为空