TensorFlow CNN 相关类与方法
2017-09-05 20:05
429 查看
embedding
tf.nn.embedding_lookup(params,ids,...)
通过id找对应的tensor.
在 Text-CNN中, 输入的word对应着一个tensor, 这个参数是可学习的, 就会用到这个函数.
示例:
embedding_shape = [vocab_size, embedding_size] embedding_weight = tf.Variable( tf.random_uniform(embedding_shape, -1.0, 1.0), name="W", dtype=tf.float32) embedded_chars = tf.nn.embedding_lookup(self.embedding_weight, input_data)
one-hot
tf.one-hot(indices, depth, on_value=None, off_value=None,axis=None, dtype=None, name=None)
即
tensorflow.python.ops.array_ops.one_hot().
Returns a one-hot tensor.
conv2d
tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None,data_format=None, name=None)
即
tensorflow.python.ops.gen_nn_ops.conv2d(),
Computes a 2-D convolution given 4-D
inputand
filtertensors. 参数见下:
input
a tensor of shape
[batch, in_height, in_width, in_channels]
filter
a tensor of shape
[filter_height, filter_width, in_channels, out_channels]
strides
A list of
ints. 1-D tensor of length 4. The stride of the sliding window for each dimension of
input. 一般情况下, strides=[1,1,1,1].
padding
A
stringfrom:
"SAME", "VALID".
SAME 对应的就是 zero-padding, 卷积后尺寸不变. VALID 对应的就是不填充, 卷积后尺寸为
input_size-filter_size+1.
Why call it a 2-D convolution, because it flattens the filter to a 2-D matrix with shape
[filter_height * filter_width * in_channels, output_channels].
max_pool
tf.nn.max_pool(value, ksize, strides, padding, data_format="NHWC", name=None)
Performs the max pooling on the input. 参数见下:
value
A 4-D
Tensorwith shape
[batch, height, width, channels]and type
tf.float32.
ksize
A list of ints that has length >= 4. The size of the window for each dimension of the input tensor.
strides
A list of ints that has length >= 4. The stride of the sliding window for each dimension of the input tensor.
一般情况下, strides=[1,ksize[1],ksize[2],1].
fully-connected
使用tf.matmul()即可.
argmax
tf.argmax(input,axis=None,name=None,dimension=None,output_type=dtypes.int64)
即
tensorflow.python.ops.math_ops.argmax().
类似于 numpy.argmax(), it returns the index with the largest value across dimensions of a tensor.
相关文章推荐
- TensorFlow RNN 相关类与方法
- win10+anaconda3(Python3.5)+TensorFlow cpu+spyder版本安装方法
- 【学习笔记】机器学习之用TensorFlow cnn 测试CIFAR-10数据集
- “Tensorflow+OpenCV“容器进行CNN数字识别训练
- Mask R-CNN Keras Tensorflow实现
- Ubuntu下深度环境的搭建opencv2.4.9+caffe+py-faster-rcnn+tensorflow的搭建
- Python+tensorflow计算整数阶乘的方法与局限性
- debug tensorflow的seq2seq的attention_decoder方法
- 暑期 tensorflow+CNN+mnist
- tensorflow c/c++库使用方法
- tensorflow Summary方法详解
- 用mobilenet模型跑tensorflow CNN的样例:image_retrain.py和label_image.py
- tensorflow & mnist & CNN
- Tensorflow + Mnist (两层CNN,两层全连接)
- tensorflow CNN for mnist
- (转)Image Segmentation with Tensorflow using CNNs and Conditional Random Fields
- Implementing a CNN for Text Classification in TensorFlow(用tensorflow实现CNN文本分类) 阅读笔记
- [052]TensorFlow Layers指南:基于CNN的手写数字识别
- windows+tensorflow+fasterRcnn---3
- 使用Python+Tensorflow的CNN技术快速识别验证码