Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def conv_relu_forward_pool_bn_droput(x,w,b,conv_param,pool_param,droput_param,gamma, beta,bn_param):
- #convolve
- a, conv_cache = conv_forward_fast(x, w, b, conv_param)
- #batchnormalize
- out_conv,cache_batch = spatial_batchnorm_forward(a, gamma , beta, bn_param)
- #nonlinearity
- out_relu,cache_relu = relu_forward(out_conv)
- #dropout
- out_drop, cache_dropout = dropout_forward(out_relu,droput_param)
- #pool
- out_pool, pool_cache = max_pool_forward_fast(out_drop, pool_param)
- out = out_pool
- cache = (conv_cache, cache_batch, cache_relu,cache_dropout,pool_cache)
- return out,cache
- def conv_relu_bn_dropout_backward(dout,cache):
- conv_cache, cache_batch, cache_relu,cache_dropout,pool_cache = cache
- ds = max_pool_backward_fast(dout, pool_cache)
- dx_drop = dropout_backward(ds,cache_dropout)
- dx_relu = relu_backward(dx_drop, cache_relu)
- dx_batch, dx_gamma, dx_beta = spatial_batchnorm_backward(dx_relu, cache_batch)
- dx, dw ,db = conv_backward_fast(dx_batch,conv_cache)
- return dx ,dw ,db ,dx_gamma , dx_beta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement