Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 1003
Kernel: Julia 1.4
using LinearAlgebra
ReLU(x) = max(0,x) x = [1 1 2 1 1; 3 1 4 1 1; 1 3 1 2 2; 1 2 1 1 1; 1 1 2 1 1] w = [ 1 -2 0; 1 0 1; -1 1 0] (xr,xc) = size(x) (wr,wc) = size(w) z = [sum(x[r:r+wr-1,c:c+wc-1] .* w) for c in 1:xc-wc+1 for r in 1:xr-wr+1] # Julia is column mayor u = ReLU.(z)
9-element Array{Int64,1}: 8 4 0 0 0 5 6 5 0
final = reshape(u, xr-wr+1, xc-wc+1)
3×3 Array{Int64,2}: 8 0 6 4 0 5 0 5 0