Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. def conv_relu_forward_pool_bn_droput(x,w,b,conv_param,pool_param,droput_param,gamma, beta,bn_param):
  2.  
  3. #convolve
  4. a, conv_cache = conv_forward_fast(x, w, b, conv_param)
  5. #batchnormalize
  6. out_conv,cache_batch = spatial_batchnorm_forward(a, gamma , beta, bn_param)
  7. #nonlinearity
  8. out_relu,cache_relu = relu_forward(out_conv)
  9. #dropout
  10. out_drop, cache_dropout = dropout_forward(out_relu,droput_param)
  11. #pool
  12. out_pool, pool_cache = max_pool_forward_fast(out_drop, pool_param)
  13.  
  14. out = out_pool
  15.  
  16. cache = (conv_cache, cache_batch, cache_relu,cache_dropout,pool_cache)
  17.  
  18. return out,cache
  19.  
  20. def conv_relu_bn_dropout_backward(dout,cache):
  21.  
  22. conv_cache, cache_batch, cache_relu,cache_dropout,pool_cache = cache
  23.  
  24. ds = max_pool_backward_fast(dout, pool_cache)
  25.  
  26. dx_drop = dropout_backward(ds,cache_dropout)
  27.  
  28. dx_relu = relu_backward(dx_drop, cache_relu)
  29.  
  30. dx_batch, dx_gamma, dx_beta = spatial_batchnorm_backward(dx_relu, cache_batch)
  31.  
  32. dx, dw ,db = conv_backward_fast(dx_batch,conv_cache)
  33.  
  34. return dx ,dw ,db ,dx_gamma , dx_beta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement