Skip to content

Instantly share code, notes, and snippets.

@ethanyanjiali
Created March 14, 2020 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanyanjiali/78bfdfdf53c7c9e7442bd6b7fb15ee73 to your computer and use it in GitHub Desktop.
Save ethanyanjiali/78bfdfdf53c7c9e7442bd6b7fb15ee73 to your computer and use it in GitHub Desktop.
Generate Gaussian Patch
scale = 1
size = 6 * sigma + 1
x, y = tf.meshgrid(tf.range(0, 6*sigma+1, 1), tf.range(0, 6*sigma+1, 1), indexing='xy')
# the center of the gaussian patch should be 1
center_x = size // 2
center_y = size // 2
# generate this 7x7 gaussian patch
gaussian_patch = tf.cast(tf.math.exp(-(tf.square(x - center_x) + tf.math.square(y - center_y)) / (tf.math.square(sigma) * 2)) * scale, dtype=tf.float32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment