Tensorflow
蹦跶的小羊羔
我养的猫长大了茶树也结了茶
展开
-
tf.shape()和tf.reshape()
一、tf.shape()tf.shape(input,name=None,out_type=tf.int32)参数(1)input:输入张量或稀疏张量;(2)name:命名;(3)out_type:默认tf.int32类型;输出返回out_type类型张量。例子:将矩阵的维度输出成一个维度的矩阵import tensorflow as tfimport n...原创 2018-10-08 11:29:07 · 4292 阅读 · 0 评论 -
tf.image.crop_and_resize()使用
tf.image.crop_and_resize()官方链接:https://tensorflow.google.cn/api_docs/python/tf/image/crop_and_resize用法tf.image.crop_and_resize( image, boxes, box_ind, crop_size, method='bil...原创 2018-10-09 10:37:17 · 2296 阅读 · 0 评论 -
tensorflow错误:InvalidArgumentError (see above for traceback): Cannot assign a device for operation
一、错误InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'shuffle_batch': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel ...原创 2019-01-02 16:23:22 · 7706 阅读 · 2 评论 -
tf.get_variable与tf.variable_scope
一、tf.Variable与tf.get_variabletensorflow提供了通过变量名称来创建或者获取一个变量的机制。通过这个机制,在不同的函数中可以直接通过变量的名字来使用变量,而不需要将变量通过参数的形式到处传递。TensorFlow中通过变量名获取变量的机制主要是通过tf.get_variable和tf.variable_scope实现的。当然,变量也可以通过tf.Var...原创 2019-03-11 10:31:34 · 263 阅读 · 0 评论 -
tf.nn.embedding_lookup()函数
一、tf.nn.embedding_lookup()tf.nn.embedding_lookup函数的用法主要是选取一个张量里面索引对应的元素。tf.nn.embedding_lookup(tensor, id):tensor就是输入张量,id就是张量对应的索引。二、代码import tensorflow as tfimport numpy as npinput_ids = t...原创 2019-03-11 15:10:34 · 803 阅读 · 0 评论 -
tf.one_hot()
一、独热编码独热编码(one-hot encoding),独热编码一般是在有监督学习中对数据集进行标注时候使用的,指的是在分类问题中,将存在数据类别的那一类用X表示,不存在的用Y表示,这里的X常常是1, Y常常是0。e.g.如果我们有3类问题,有数据(Xi,Yi),其中类别Yi有3种取值。如果Yj为第一类那么其独热编码为:如果Yj为第二类那么其独热编码为:只对存在有该类别的数的...原创 2019-03-12 09:56:17 · 741 阅读 · 0 评论 -
Tensorflow模型通过ckpt获取参数
ckpt是Tensorflow保存的已知模型,获取参数名:import tensorflow as tffrom tensorflow.python import pywrap_tensorflow model_dir = "./train_results/checkpoint/" ckpt = tf.train.get_checkpoint_state(model_dir)ck...原创 2019-05-08 09:55:55 · 1046 阅读 · 0 评论