Created
March 14, 2020 21:06
-
-
Save ethanyanjiali/78bfdfdf53c7c9e7442bd6b7fb15ee73 to your computer and use it in GitHub Desktop.
Generate Gaussian Patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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