Tensorflow
tensorflow相关知识
ZZY_dl
积极向上 自信阳光
展开
-
Tensorflow error(三):failed to get convolution algorithm,cuDNN failed to initialize
文章目录错误情况错误原因错误情况错误原因1.cuDNN, CUDA, tensorflow, GPU驱动版本不一致。在不同虚拟环境中配置不同版本的tf以及CUDA并根据代码所需环境切换。2.默认情况下,TensorFlow 会映射进程可见的所有 GPU的几乎全部内存。这是为了减少内存碎片,更有效地利用设备上相对宝贵的 GPU 内存资源。为了将 TensorFlow 限制为使用一组特定的 GPU,我们使用tf.config.experimental.set_visible_devices方法。原创 2021-04-22 16:46:40 · 92 阅读 · 0 评论 -
Tensorflow学习笔记(二):各种tf类型的函数用法集合
import tensorflow as tfimport numpy as np"""tf.constant可用于创建tensor类型的int,float,bool"""a = tf.constant([1,2],dtype=tf.int32)b = tf.constant(1.2,dtype=tf.double)c = tf.constant([True,False])d = tf.constant('hello world')print(a) # Tensor("Const:0", s原创 2021-02-08 21:37:57 · 351 阅读 · 0 评论 -
Tensorflow error(二):x and y must have the same dtype, got tf.float32 != tf.int32
原代码 with tf.GradientTape() as tape: # 打平操作,[b, 28, 28] => [b, 784] x = tf.reshape(x, (-1, 28*28)) # Step1. 得到模型输出output [b, 784] => [b, 10] out = model(x) # [b] => [b, 10] y_onehot = tf.one_hot(y原创 2021-02-01 18:29:53 · 1450 阅读 · 0 评论 -
Tensorflow error(一):__iter__() is only supported when eager execution is enabled.
错误语句:RuntimeError: iter() is only supported inside of tf.function or when eager execution is enabled.解决方法:I fixed it by enabling eager execution after importing tensorflow:import tensorflow as tf tf.enable_eager_execution()转载:https://stackoverflow..转载 2021-02-01 17:24:02 · 716 阅读 · 0 评论 -
TensorFlow学习笔记(一): tf.Variable() 和tf.get_variable()详解
对于tf.Variable和tf.get_variable,这两个都是在我们训练模型的时候常遇到的函数,我们首先要知道懂得它的语法格式、常用的语法格式的作用以及在实际代码中是如何调用、如何运行的,运行之后具有什么样的作用。tf.Variable()作用:用于生成一个初始值为initial-value的变量。必须指定初始化值。语法格式如下:tf.Variable(initial_value=None, trainable=True, collections=None, validate_shape=T原创 2021-01-19 20:47:53 · 5304 阅读 · 2 评论