Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a custom filter in convolution layer for tensorflow

Tags:

tensorflow

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

or

tf.truncated_normal

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

like image 961
ivanmkc Avatar asked Jun 27 '16 21:06

ivanmkc


1 Answers

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

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.

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

Hope that helps!

like image 148
Peter Hawkins Avatar answered Jan 02 '23 21:01

Peter Hawkins