Skip to content

Instantly share code, notes, and snippets.

@flowpoint
Last active February 1, 2018 14:49
Show Gist options
  • Save flowpoint/f04e845838db6a9ab0cbbe68ad3ba5a3 to your computer and use it in GitHub Desktop.
Save flowpoint/f04e845838db6a9ab0cbbe68ad3ba5a3 to your computer and use it in GitHub Desktop.
tensorflow atrous conv1d
def atrous_conv1d(value, filters, rate, padding, name=None):
'''wrapper for tf.nn.convolution to atrous_conv1d
lets you choose the filters
usage:
b = tf.placeholder(shape=(None, 1, 4096,1), dtype=tf.float32)
atrous_conv1d(b, filters=tf.ones((1, 4096, 1)),rate=2, padding='VALID')
b = tf.placeholder(shape=(None, 4096), dtype=tf.float32)
atrous_conv1d(b, filters=tf.ones((1, 4096, 1)),rate=2, padding='VALID')
correctness not guaranteed'''
return tf.squeeze(tf.nn.convolution(
input=tf.expand_dims(value,1),
filter=tf.expand_dims(filters,1),
padding=padding,
dilation_rate=np.broadcast_to(rate, (2,)),
name=name), 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment