在 tensorflow 卷积层中使用自定义过滤器 [英] Using a custom filter in convolution layer for tensorflow

查看:31
本文介绍了在 tensorflow 卷积层中使用自定义过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在从各种教程中学习 Tensorflow,我想知道是否可以为卷积网络定义一个自定义过滤器来使用.例如,如果我知道特征中存在有意义的结构,使得所有其他特征都是相关的,我想定义一个看起来像 [0 1 0 1 0 1] 的过滤器.

I've been learning Tensorflow from a variety of tutorials and am wondering if it's possible to define a custom filter for convolution nets to use. For example, if I know there is meaningful structure in the features, such that every other feature is related, I want to define a filter that looks like [0 1 0 1 0 1].

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None)

到目前为止我看到的所有例子都使用:

All the examples I've seen so far use:

tf.random_normal

tf.truncated_normal

用于过滤器参数.我可以并且将 [0 1 0 1] 放在过滤器参数中是否有意义?

for the filter argument. Can I and does it make sense for me to put [0 1 0 1] in the filter argument instead?

推荐答案

你当然可以!您可以在卷积过滤器中放入您喜欢的任何(浮点)值.

You most certainly can! You can put any (floating-point) values you like in the convolution filter.

然而,通常卷积过滤器中的值是变量,Tensorflow 在训练期间学习其值,而不是常量."tf.random_normal" 和 "tf.truncated_normal" 值仅用于设置过滤器的初始值.这些变量的值将在训练过程中通过梯度下降算法进行更新.

However, usually the values in the convolution filter are variables whose values Tensorflow learns during training, not constants. The "tf.random_normal" and "tf.truncated_normal" values are used just for setting the initial values of the filter. The values of those variables will be updated during training by the gradient descent algorithm.

有关使用卷积神经网络进行训练的示例,请查看此处的教程:https://www.tensorflow.org/versions/r0.9/tutorials/deep_cnn/index.html

For an example of training with a convolutional neural network, take a look at the tutorial here: https://www.tensorflow.org/versions/r0.9/tutorials/deep_cnn/index.html

希望有帮助!

这篇关于在 tensorflow 卷积层中使用自定义过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆