summaryrefslogtreecommitdiff
path: root/conv-flux.jl
diff options
context:
space:
mode:
Diffstat (limited to 'conv-flux.jl')
-rw-r--r--conv-flux.jl17
1 files changed, 17 insertions, 0 deletions
diff --git a/conv-flux.jl b/conv-flux.jl
new file mode 100644
index 0000000..de33910
--- /dev/null
+++ b/conv-flux.jl
@@ -0,0 +1,17 @@
+using Flux, Images, FileIO, ImageView
+
+img_gray = load("./cameraman.png") .|> Gray
+
+img_tensor = Float32.(channelview(img_gray))
+img_tensor = reshape(img_tensor, size(img_tensor)..., 1, 1)
+
+kernel = Float32[1 0 -1; 2 0 -2; 1 0 -1]
+
+weight = reshape(kernel, 3, 3, 1, 1)
+conv_layer = Conv(weight, false)
+
+conv_result = conv_layer(img_tensor)
+
+result_img = colorview(Gray, conv_result[:, :, 1, 1])
+
+imshow(result_img)