2 // Copyright (c) 2016 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 #include "primitive.hpp"
22 /// @addtogroup cpp_api C++ API
24 /// @addtogroup cpp_topology Network Topology
26 /// @addtogroup cpp_primitives Primitives
29 typedef enum { /*:int32_t*/
30 lrn_norm_region_across_channel,
31 lrn_norm_region_within_channel
34 /// @brief Local response normalization
35 /// @details LRN layer as described in chapter 3.3 of "ImageNet Classification with Deep Convolutional
36 /// Neural Networks" by Khrizevsky, Sutskever, Hinton. @n See: http://www.cs.toronto.edu/~fritz/absps/imagenet.pdf
38 /// b(i,x,y) = a(i,x,y) / (k+alpha*sum(min(N-1, i+n/2); j=max(0,i-n/2); a(j,x,y)^2))
40 /// @li b(i,x,y) : value at x, y from i-th feature map after normalization
41 /// @li a(i,x,y) : value at x, y from i-th feature map before normalization
42 /// @li N : number of feature maps
43 /// @li n : size of normalization
44 /// @li k, alpha, beta : hyper parameters (equal to 2, 10e-4, 0.75 in paper).
45 struct lrn : public primitive_base<lrn> {
46 CLDNN_DECLARE_PRIMITIVE(lrn)
48 /// @brief Constructs LRN primitive.
49 /// @param id This primitive id.
50 /// @param input Input primitive id.
51 /// @param size Size of normalization.
52 /// @param k Hyper parameter "k".
53 /// @param alpha Hyper parameter "alpha".
54 /// @param beta Hyper parameter "beta".
55 /// @param lrn_norm_region Normalize across or within channel
56 lrn(const primitive_id& id,
57 const primitive_id& input,
62 lrn_norm_region lrn_norm_region,
63 const padding& output_padding = padding())
64 : primitive_base(id, {input}, output_padding),
69 norm_region(lrn_norm_region) {}
71 /// @brief Size of normalization.
73 /// @brief Hyper parameter "k".
75 /// @brief Hyper parameter "alpha".
77 /// @brief Hyper parameter "beta".
79 /// @brief Normalize across or within channel
80 lrn_norm_region norm_region;