![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
tensorflow2.0学习
逆着tensor
一枚初学tensorflow2.0的菜菜
展开
-
错误ModuleNotFoundError: No module named ‘xlwt‘
错误代码:import xlwtModuleNotFoundError: No module named 'xlwt'解决办法:1 activate tf22 pip install xlwt完成!原创 2021-08-11 22:00:50 · 4603 阅读 · 0 评论 -
问题module ‘tensorboard-lazy’ has no attribute ‘lazy’
问题:AttributeError: module ‘tensorboard-lazy’ has no attribute ‘lazy’解决办法:1 打开cmd,激活环境。2 先卸载安装的tensorboard 和tensorflow.tensorboard。pip uninstall tensorboardpip uninstall tensorflow.tensorboard3 再安装新的版本。pip install tensorboard==2.3.0pip install ten原创 2021-06-01 16:12:21 · 2189 阅读 · 0 评论 -
TF2.0错误ModuleNotFoundError: No module named ‘tensorboard
错误代码:ModuleNotFoundError: No module named 'tensorboard解决办法:pip install tensorflow.tensorboard而不是 pip install tensorboard成功!!原创 2021-05-31 17:29:27 · 426 阅读 · 0 评论 -
训练自己的SSD错误‘conv4_3_norm_mbox_loc‘ shape mismatch维度不匹配
错误描述用TF2.2版本训练自己的SSD模型,出现shape维度不匹配的问题。‘conv4_3_norm_mbox_loc’ shape mismatch原因:自己的数据集不是VOC2007的20类,而是5类,使用预训练模型**ssd_weight.py,**就会出现这个情况,需要重新训练模型.,生成自己的权重。运行 train.py%load train.py 然后再运行ssd.py注意修改类别数,还有权重。model_path和classes_path的路径。这里路径如果出现错误,请加载绝原创 2021-03-30 09:45:47 · 555 阅读 · 0 评论 -
错误ValueError: too many values to unpack (expected 5) During handling of the above exception。
错误显示ValueError: too many values to unpack (expected 5) During handling of the above, another exception occurred:错误代码dict = {}for i in dict(): pass解决办法1 是否在遍历字典的时候没有使用items;dict = {}for i in dict.items():pass2 在调用函数的时候,如果函数返回值是5个,而你只写了3个的话原创 2021-03-30 09:35:23 · 4176 阅读 · 0 评论 -
tf2.2运行SSD目标检测,出现错误ipykernel_launcher.py: error: unrecognized arguments:
*错误代码11 ipykernel_launcher.py: error: unrecognized arguments:错误提示import argparseparser = argparse.ArgumentParser()args = parser.parse_args()解决办法:将parser.parse_args() 改为 parser.parse_known_args()[0]import argparseparser = argparse.ArgumentP原创 2021-03-30 09:31:09 · 1948 阅读 · 1 评论 -
读取文件错误 OSError: [Errno 22] Invalid argument:
错误代码:OSError: [Errno 22] Invalid argument:解决办法:1 将相对路径改为绝对路径;2 将“/”改为“\” 试一下;3 在路径前面加上r;4 修改自己的文件名,文件名千万不要使用空格,不要使用空格,不要使用空格。 重要的事情说三遍1!1!!5 不要复制粘贴路径,将路径 重新手敲出来。(因为这个问题,我大概浪费了一下午时间,反复改都出现以上错误。)如果还是不行,那就把这些全部试一遍,总有一个是对的。...原创 2021-03-29 19:07:09 · 33158 阅读 · 13 评论 -
错误 WARNING:tensorflow:From <ipython-input-3-ddde76583c97>:112: Model.
错误显示:WARNING:tensorflow:From :112: Model.fit_generator (from tensorflow.python.keras.engine.training) is deprecated and will be removed in a future version. Instructions for updating: Please use Model.fit, which supports generators.原因新版的tf,取消了Model.fit_原创 2021-03-29 19:01:24 · 1702 阅读 · 0 评论 -
错误解决ModuleNotFoundError: No module named ‘imutils‘
ModuleNotFoundError: No module named 'imutils’解决办法:打开cmd激活你的环境:activate tensorflow安装: pip install imutils安装完成!原创 2021-03-25 09:25:59 · 6003 阅读 · 1 评论 -
错误NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model
tf2.0训练网络,使用官方预训练模型和权重时,在保存模型和参数时,出现这个错误:代码:model.save('model36_5.h5')model.save_weights('weight_tf_model36_5.h5')报错信息 NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It原创 2021-02-03 19:52:58 · 1674 阅读 · 0 评论 -
错误AttributeError: ‘tensorflow.python.framework.ops.EagerTensor‘ object has no attribute ‘compile‘
错误代码:1 AttributeError: ‘tensorflow.python.framework.ops.EagerTensor’ object has no attribute ‘compile’2AttributeError:Tensor.graph is meaningless when eager execution is enabled.AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has n原创 2021-01-19 21:24:37 · 3692 阅读 · 2 评论 -
错误NameError: name ‘tfa‘ is not defined
@NameError: name ‘tfa’ is not defined出错代码optimizer = tfa.optimizers.SWA(tf.keras.optimizers.SGD(lr=2.0), 100, 10)解决问题1 下载内置模块pip install tensorflow-addons#pip install tensorflow-addonsimport tensorflow_addons as tfaoptimizer = tfa.optimizers.SWA(t原创 2021-01-18 12:05:04 · 1037 阅读 · 0 评论 -
tf2.0如何读取数据集图片jpg格式的标签文件夹
@tf2.0如何读取数据集jpg格式的标签文件夹,即y_test我们的数据集是如下形式,内部都是jpg格式:一 tensorflow2.0-从文件夹中读取图片数据导入包:from tensorflow.keras.preprocessing.image import ImageDataGeneratorImageDataGenerator-图片生成器,使用它在batch中对数据进行增强,扩充数据集大小,从而增强模型的泛化能力。keras.preprocessing.image.ImageD原创 2020-12-25 21:55:18 · 798 阅读 · 0 评论 -
错误InvalidArgumentError: Expected ‘tf.Tensor(False, shape=(), dtype=bool)‘ to be true. Summarized dat
错误显示:InvalidArgumentError: Expected ‘tf.Tensor(False, shape=(), dtype=bool)’ to be true. Summarized data: b’Unable to decode bytes as JPEG, PNG, GIF, or BMP’图片显示:错误原因:如果某个操作接收到的输入张量具有无效的值或形状,则可能发生该情况。汇总数据时,b’无法将字节解码为JPEG,PNG,GIF或BMP’格式。解决办法试了很多,但是一原创 2020-12-16 20:47:36 · 1730 阅读 · 0 评论 -
数据集分享*cifar-10 cifar-100 猫狗 康奈尔抓取数据集**
每次找添加链接描述公开数据集都很麻烦,找不到。现在把自己的知道的全部共享了有 cifar-10 cifar-100 猫狗 康奈尔抓取数据集链接:https://pan.baidu.com/s/1xHMT-KBk235P9Gsv1tWIJw提取码:v1jn复制这段内容后打开百度网盘手机App,操作更方便哦如果链接失败,可私我。...原创 2020-12-15 11:24:14 · 531 阅读 · 1 评论 -
tf2.0 错误AttributeError: module ‘tensorflow‘ has no attribute ‘enable_eager_execution‘
tensorflow2.0出现错误AttributeError: module ‘tensorflow’ has no attribute ‘enable_eager_execution’错误代码:启用动态图机制tf.enable_eager_execution()如图所示:错误原因:如果tensorflow为 2.0 版本 移除 了直接调用 enable_eager_execution() 的方式。新版本2.0加入了 eager模式,不需要调用。解决办法:把tf.enable_eage原创 2020-12-09 19:32:26 · 3420 阅读 · 0 评论 -
加载模型出现WARNING:tensorflow:Error in loading the saved optimizer state.
警告标识:WARNING:tensorflow:Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.加载模型时。老是出现如下警告,虽然对代码没有影响,但是还是很烦。这个警告大概说:在加载保存的优化器状态时出错。因此,模型从一个新初始化的优化器开始。也就是每次重新加载模型,初始化的优化器都不一样。不用管他就好了。没有其原创 2020-11-04 19:47:08 · 3073 阅读 · 3 评论 -
ModuleNotFoundError: No module named ‘Resnet‘
错误代码:解决办法:pip install Resnet原创 2020-07-05 17:22:42 · 7386 阅读 · 2 评论 -
ModuleNotFoundError: No module named ‘tensorflow_datasets‘
出现错误,如下所示:解决办法:打开cmdactivate tensorflow_gpupip install tensorflow_datasets安装成功!原创 2020-07-04 15:52:18 · 1022 阅读 · 0 评论 -
MemoryError: Unable to allocate 469. MiB for an array with shape (20000, 32, 32, 3) and data type fl
错误显示:MemoryError: Unable to allocate 469. MiB for an array with shape (20000, 32, 32, 3) and data type float64错误原因:内存错误:无法分配469。用于具有形状(20000、32、32、3)和数据类型float64的数组的MiB。触发了系统的过量处理模式(overcommit handing)。这个矩阵似乎要占用的空间太大,所以系统就提前禁止创建了。解决办法:关闭其他无关的running原创 2020-06-04 12:15:41 · 20766 阅读 · 3 评论 -
InvalidArgumentError: Can not squeeze dim[1], expected a dimension of 1, got 10 for metrics/acc/
报错代码显示:InvalidArgumentError: Can not squeeze dim[1], expected a dimension of 1, got 10 for ‘metrics/acc/Squeeze’ (op: ‘Squeeze’) with input shapes: [?,10].错误原因:使用稀疏分类交叉熵的损失函数,模型的真实输出值得是一个索引index而不是one hot编码,比如你给定的真实输出值应该是0而非[1, 0, 0, 0, 0]解决办法1 修改损失函原创 2020-06-03 20:19:04 · 1961 阅读 · 0 评论 -
UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initial
训练一个卷积神经网络时,报这个错误。错误显示代码:无法获取卷积算法。这可能是因为cuDNN初始化失败,所以请尝试查看上面是否打印了警告日志消息。UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.错误原因:报错翻原创 2020-05-29 11:05:45 · 4513 阅读 · 7 评论 -
ResourceExhaustedError: OOM when allocating tensor with shape[512] and type float on /job:localhost
运行resnet50程序时,出现这个错误。**原代码地址:**https://github.com/calmisential/TensorFlow2.0_ResNet错误显示:ResourceExhaustedError: OOM when allocating tensor with shape[512] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc[[node res_原创 2020-05-26 17:28:06 · 12899 阅读 · 0 评论 -
tensorflow2.0运行程序过程中错误汇总
ModuleNotFoundError: No module named ‘cv2’打开 CMD,activate tensorflow_gpupip install opencv-pythonModuleNotFoundError: No module named ‘tqdm’打开 CMD,activate tensorflow_gpupip install tqdm安装成功就行了。原创 2020-05-25 16:43:47 · 492 阅读 · 0 评论 -
word_index = imdb.get_word_index()由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败
执行代码是:imdb=keras.datasets.imdb(train_x, train_y), (test_x, text_y)=keras.datasets.imdb.load_data(num_words=10000)word_index = imdb.get_word_index()结果出错:Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/imdb_word_index.j原创 2020-05-22 14:54:12 · 1981 阅读 · 5 评论 -
解决问题 ModuleNotFoundError: No module named sklearn
原代码如下:from sklearn.model_selection import train_test_split错误显示:ModuleNotFoundError: No module named ‘sklearn’解决办法:1 打开cmd或者anaconda prompt2 activate tensorflow_gpu3 conda install sklearn在 cmd 中执行代码 conda install sklearn,又出错:PackagesNotFoundError:原创 2020-05-22 14:51:51 · 29840 阅读 · 5 评论 -
错误解决 ValueError: The estimator KerasClassifier should be a classifier.
ValueError: The estimator KerasClassifier should be a classifier.原代码:原创 2020-05-22 11:25:28 · 1763 阅读 · 3 评论 -
错误 Fashion-mnist下载失败的问题(连接尝试失败)
wen10 tf2.0 notebook运行程序代码如下(train_images, train_labels), (test_images, test_labels) = keras.datasets.fashion_mnist.load_data()原创 2020-05-19 10:12:44 · 919 阅读 · 0 评论 -
官网下载cifar10数据集过程太慢,自行下载之后还一直重复下载的问题
Win10+tensorflow2.0+GPU下载cifar-10数据集。运行程序时,数据集下载一直没反应,导致程序运行不出来。执行代码是:(x_train, y_train), (x_test, y_test) = tf.keras.datasets.cifar10.load_data()官网下载地址是:https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz所以我从百度网盘里面下载了数据集,总共163MB。然后,修改文件名称。cifa原创 2020-05-17 11:27:24 · 2023 阅读 · 2 评论 -
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your m
错误显示:ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected.代码如下:(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()x_train = x_train.astype(‘flo原创 2020-05-17 11:14:25 · 5542 阅读 · 0 评论 -
出错 InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 32), m=64, n=32, k=784
错误代码显示// 代码如下所示。主要是tensorflow2.0-GPU训练mnist数据集时,出错:InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 32), m=64, n=32, k=784// An highlighted blockvar foo = 'bar';# 模型的训练、验证和测试与训练模型完全相同# 下面使用mnist数据集进行展示(x_train, y_train), (原创 2020-05-15 22:09:55 · 5453 阅读 · 0 评论 -
求解:CSDN博文自带编辑器出现卡死
使用CSDN博文自带的编辑器编辑文档时,当复制(ctrl+c)代码到编辑器里面,之后总会出现下面这种情况。除了退出,其他全没反应,请广大网友解答一下,是什么问题呢??原创 2020-05-15 11:03:30 · 262 阅读 · 0 评论 -
报错importError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work
安装可视化pydot时出现这个错误。##错误原因我先在cmd中安装了graphviz,然后再pip install pydot时,就出现错误提示:importError: Failed to import pydot. You must install pydot and graphviz for pydotprint to work。##解决看了广大网友的建议。我把graphviz卸载了,重新安装pydot。在CMD里面显示安装成功了;但是在notebook中跑程序时,还是之前这个错误——impo原创 2020-05-15 21:50:14 · 2242 阅读 · 0 评论 -
报错ProfilerNotRunningError: Cannot stop profiling. No profiler is running.
这里写目录标题问题所在问问题所在使用回调函数callbacks时,报错。错误代码是:callbacks = [ tf.keras.callbacks.EarlyStopping(patience=2, monitor='val_loss'), tf.keras.callbacks.TensorBoard(log_dir='./logs') ] model.fit(train_x, train_y, batch_size=16, epochs=5, callbacks=callbacks, valida原创 2020-05-15 11:13:12 · 494 阅读 · 0 评论 -
报错 FileNotFoundError: [Errno 2] File./income.csv does not exist:
这里写目录标题报错信息如何解决第一种修改第二种修改第三种修改报错信息FileNotFoundError Traceback (most recent call last) in ----> 1 data=pd.read_csv(“C:/Users/Tangliny/tensorflow2.0-python/dataset/income.csv”)~\anaconda3\envs\tensorflow_gpu\lib\site-packages\原创 2020-05-13 21:23:47 · 2946 阅读 · 6 评论 -
错误moduleNotFoundError: No module named 'pandas'
错误moduleNotFoundError: No module named ‘pandas’ModuleNotFoundError: No module named 'pandas’解决办法activate tensorflow_gpupip install pandas原创 2020-05-13 14:30:14 · 3028 阅读 · 0 评论 -
错误如何解决 InvalidArgumentError: Incompatible shapes: [20000,1] vs. [256,1]
@错误如何解决 InvalidArgumentError: Incompatible shapes: [20000,1] vs. [256,1] [Op:Sub] name: sub/错误显示InvalidArgumentError Traceback (most recent call last) in 10 for epoch in range(10):11 for step,(x,y) in enumerate(dataset):—>原创 2020-05-13 13:22:00 · 11300 阅读 · 9 评论 -
错误 InternalError: Blas GEMV launch failed: m=2, n=256 [Op:MatMul] name: MatMul/
@错误 InternalError: Blas GEMV launch failed: m=2, n=256 [Op:MatMul] name: MatMul/问题问题原因内存占用过多问题解决办法关闭任务管理器中的python关闭开的cmd关闭juptyter notebook重新打开jupyter notebook原创 2020-05-13 12:55:56 · 1069 阅读 · 2 评论 -
错误moduleNotFoundError: No module named 'matplotlib'
错误ModuleNotFoundError: No module named ‘matplotlib’问题tensorflow 2.0 中jupyter notebook编写线性回归例子,出现ModuleNotFoundError: No module named 'matplotlib’错误解决办法好了,重新加载程序,已经可以用了。...原创 2020-05-13 10:35:14 · 630 阅读 · 0 评论 -
Win10系统+anaconda环境下安装tensorflow2.0(GPU)详细版
Win10系统+anaconda环境下安装tensorflow2.0(GPU)详细版之前在win7系统安装了anaconda3.4.0,tensorflow1.6-cpu版本的。但是由于电脑反应太慢,最简单的手写数字识别都很慢,得跑很长时间。因此现在换了一台电脑,用的是英伟达GTX1660Ti的显卡。1. 安装CUDN10.0必须安装10.0版本的,tf2.0只适合10.0版本的,其他的不行...原创 2020-04-11 22:23:41 · 1738 阅读 · 1 评论