@@ -10,9 +10,9 @@ function psize(p, x)
10
10
end
11
11
end
12
12
13
- function im2col_2d! {T} (img:: AbstractArray{T,3} , col:: AbstractArray{T,2} , width:: Int , height:: Int , channels:: Int ,
13
+ function im2col_2d! (img:: AbstractArray{T,3} , col:: AbstractArray{T,2} , width:: Int , height:: Int , channels:: Int ,
14
14
kernel_w:: Int , kernel_h:: Int , pad_w:: Int , pad_h:: Int , stride_w:: Int , stride_h:: Int ,
15
- dil_w:: Int , dil_h:: Int , mode:: Int )
15
+ dil_w:: Int , dil_h:: Int , mode:: Int ) where T
16
16
17
17
height_col = div (height + 2 pad_h - (kernel_h - 1 ) * dil_h - 1 , stride_h) + 1
18
18
width_col = div (width + 2 pad_w - (kernel_w - 1 ) * dil_w - 1 , stride_w) + 1
@@ -42,9 +42,9 @@ function im2col_2d!{T}(img::AbstractArray{T,3}, col::AbstractArray{T,2}, width::
42
42
end
43
43
end
44
44
45
- function col2im_2d! {T} (col:: AbstractArray{T,2} , img:: AbstractArray{T,3} , width:: Int , height:: Int ,
45
+ function col2im_2d! (col:: AbstractArray{T,2} , img:: AbstractArray{T,3} , width:: Int , height:: Int ,
46
46
channels:: Int , kernel_w:: Int , kernel_h:: Int , pad_w:: Int , pad_h:: Int , stride_w:: Int ,
47
- stride_h:: Int , dil_w:: Int , dil_h:: Int , mode:: Int )
47
+ stride_h:: Int , dil_w:: Int , dil_h:: Int , mode:: Int ) where T
48
48
49
49
height_col = div (height + 2 pad_h - (kernel_h - 1 ) * dil_h - 1 , stride_h) + 1
50
50
width_col = div (width + 2 pad_w - (kernel_w - 1 ) * dil_w - 1 , stride_w) + 1
@@ -71,9 +71,9 @@ function col2im_2d!{T}(col::AbstractArray{T,2}, img::AbstractArray{T,3}, width::
71
71
end
72
72
end
73
73
74
- function im2col_3d! {T} (img:: AbstractArray{T,4} , col:: AbstractArray{T,2} , width:: Int , height:: Int , depth:: Int ,
74
+ function im2col_3d! (img:: AbstractArray{T,4} , col:: AbstractArray{T,2} , width:: Int , height:: Int , depth:: Int ,
75
75
channels:: Int , kernel_w:: Int , kernel_h:: Int , kernel_d:: Int , pad_w:: Int , pad_h:: Int , pad_d:: Int ,
76
- stride_w:: Int , stride_h:: Int , stride_d:: Int , dil_w:: Int , dil_h:: Int , dil_d:: Int , mode:: Int )
76
+ stride_w:: Int , stride_h:: Int , stride_d:: Int , dil_w:: Int , dil_h:: Int , dil_d:: Int , mode:: Int ) where T
77
77
78
78
height_col = div (height + 2 pad_h - (kernel_h - 1 ) * dil_h - 1 , stride_h) + 1
79
79
width_col = div (width + 2 pad_w - (kernel_w - 1 ) * dil_w - 1 , stride_w) + 1
@@ -107,10 +107,10 @@ function im2col_3d!{T}(img::AbstractArray{T,4}, col::AbstractArray{T,2}, width::
107
107
end
108
108
end
109
109
110
- function col2im_3d! {T} (col:: AbstractArray{T,2} , img:: AbstractArray{T,4} , width:: Int , height:: Int ,
110
+ function col2im_3d! (col:: AbstractArray{T,2} , img:: AbstractArray{T,4} , width:: Int , height:: Int ,
111
111
depth:: Int , channels:: Int , kernel_w:: Int , kernel_h:: Int , kernel_d:: Int ,
112
112
pad_w:: Int , pad_h:: Int , pad_d:: Int , stride_w:: Int , stride_h:: Int , stride_d:: Int ,
113
- dil_w:: Int , dil_h:: Int , dil_d:: Int , mode:: Int )
113
+ dil_w:: Int , dil_h:: Int , dil_d:: Int , mode:: Int ) where T
114
114
115
115
height_col = div (height + 2 pad_h - (kernel_h - 1 ) * dil_h - 1 , stride_h) + 1
116
116
width_col = div (width + 2 pad_w - (kernel_w - 1 ) * dil_w - 1 , stride_w) + 1
@@ -170,8 +170,8 @@ function im2col_dims(w,y)
170
170
return (r, c)
171
171
end
172
172
173
- function conv2d! {T} (y:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
174
- padding= 0 , stride= 1 , dilation= 1 , mode= 0 , alpha= T (1 ))
173
+ function conv2d! (y:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} ;
174
+ padding= 0 , stride= 1 , dilation= 1 , mode= 0 , alpha= T (1 )) where T
175
175
if mode != 0 && mode != 1 ; throw (ArgumentError (" conv2d only supports mode=0 or 1." )); end
176
176
Wx,Hx,Cx,Nx = size (x)
177
177
Ww,Hw,C1,C2 = size (w)
@@ -192,8 +192,8 @@ function conv2d!{T}(y::AbstractArray{T,4}, x::AbstractArray{T,4}, w::AbstractArr
192
192
return y
193
193
end
194
194
195
- function conv2d_grad_w! {T} (dw:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} , dy:: AbstractArray{T,4} ;
196
- padding= 0 , stride= 1 , dilation= 1 , mode= 0 , alpha= 1 )
195
+ function conv2d_grad_w! (dw:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} , dy:: AbstractArray{T,4} ;
196
+ padding= 0 , stride= 1 , dilation= 1 , mode= 0 , alpha= 1 ) where T
197
197
# dw = x'*dy
198
198
Wx,Hx,Cx,Nx = size (x)
199
199
Ww,Hw,C1,C2 = size (w)
@@ -217,8 +217,8 @@ function conv2d_grad_w!{T}(dw::AbstractArray{T,4}, x::AbstractArray{T,4}, w::Abs
217
217
return dw
218
218
end
219
219
220
- function conv2d_grad_x! {T} (dx:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} , dy:: AbstractArray{T,4} ;
221
- padding= 0 , stride= 1 , dilation= 1 , mode= 0 , alpha= 1 )
220
+ function conv2d_grad_x! (dx:: AbstractArray{T,4} , x:: AbstractArray{T,4} , w:: AbstractArray{T,4} , dy:: AbstractArray{T,4} ;
221
+ padding= 0 , stride= 1 , dilation= 1 , mode= 0 , alpha= 1 ) where T
222
222
# dx = dy*w'
223
223
Wx,Hx,Cx,Nx = size (x)
224
224
Ww,Hw,C1,C2 = size (w)
@@ -261,8 +261,8 @@ function col2im2d!(w::AbstractArray{T,4}, x::AbstractArray{T,4}, x2::AbstractArr
261
261
return x
262
262
end
263
263
264
- function conv3d! {T} (y:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} ;
265
- padding= 0 , stride= 1 , dilation = 1 , mode= 0 , alpha= T (1 ))
264
+ function conv3d! (y:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} ;
265
+ padding= 0 , stride= 1 , dilation = 1 , mode= 0 , alpha= T (1 )) where T
266
266
if mode != 0 && mode != 1 ; throw (ArgumentError (" conv3d only supports mode=0 or 1." )); end
267
267
Wx,Hx,Dx,Cx,Nx = size (x)
268
268
Ww,Hw,Dw,C1,C2 = size (w)
@@ -285,8 +285,8 @@ function conv3d!{T}(y::AbstractArray{T,5}, x::AbstractArray{T,5}, w::AbstractArr
285
285
return y
286
286
end
287
287
288
- function conv3d_grad_w! {T} (dw:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} , dy:: AbstractArray{T,5} ;
289
- padding= 0 , stride= 1 , dilation = 1 , mode= 0 , alpha= 1 )
288
+ function conv3d_grad_w! (dw:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} , dy:: AbstractArray{T,5} ;
289
+ padding= 0 , stride= 1 , dilation = 1 , mode= 0 , alpha= 1 ) where T
290
290
# dw = x'*dy
291
291
Wx,Hx,Dx,Cx,Nx = size (x)
292
292
Ww,Hw,Dw,C1,C2 = size (w)
@@ -310,8 +310,8 @@ function conv3d_grad_w!{T}(dw::AbstractArray{T,5}, x::AbstractArray{T,5}, w::Abs
310
310
return dw
311
311
end
312
312
313
- function conv3d_grad_x! {T} (dx:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} , dy:: AbstractArray{T,5} ;
314
- padding= 0 , stride= 1 , dilation = 1 , mode= 0 , alpha= 1 )
313
+ function conv3d_grad_x! (dx:: AbstractArray{T,5} , x:: AbstractArray{T,5} , w:: AbstractArray{T,5} , dy:: AbstractArray{T,5} ;
314
+ padding= 0 , stride= 1 , dilation = 1 , mode= 0 , alpha= 1 ) where T
315
315
# dx = dy*w'
316
316
Wx,Hx,Dx,Cx,Nx = size (x)
317
317
Ww,Hw,Dw,C1,C2 = size (w)
0 commit comments