import tensorflow as tf
import numpy as np
def sobel_filter():
fx = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]).astype(np.float32)
fy = np.array([[-1, -2, -1], [0, 0, 0], [1, 2, 1]]).astype(np.float32)
fx = np.stack((fx, fx), axis=2)
fy = np.stack((fy, fy), axis=2)
print(fx)
print("#############")
print(fy)
fx = np.reshape(fx, (3, 3, 2, 1))
fy = np.reshape(fy, (3, 3, 2, 1))
return fx, fy
x,y=sobel_filter()
print(x)
print("############")
print(y)
[[[-1. -1.]
[ 0. 0.]
[ 1. 1.]]
[[-2. -2.]
[ 0. 0.]
[ 2. 2.]]
[[-1. -1.]
[ 0. 0.]
[ 1. 1.]]]
#############
[[[-1. -1.]
[-2. -2.]
[-1. -1.]]
[[ 0. 0.]
[ 0. 0.]
[ 0. 0.]]
[[ 1. 1.]
[ 2. 2.]
[ 1. 1.]]]
#######
[[[[-1.]
[-1.]]
[[ 0.]
[ 0.]]
[[ 1.]
[ 1.]]]
[[[-2.]
[-2.]]
[[ 0.]
[ 0.]]
[[ 2.]
[ 2.]]]
[[[-1.]
[-1.]]
[[ 0.]
[ 0.]]
[[ 1.]
[ 1.]]]]
############
[[[[-1.]
[-1.]]
[[-2.]
[-2.]]
[[-1.]
[-1.]]]
[[[ 0.]
[ 0.]]
[[ 0.]
[ 0.]]
[[ 0.]
[ 0.]]]
[[[ 1.]
[ 1.]]
[[ 2.]
[ 2.]]
[[ 1.]
[ 1.]]]]