8 #ifndef BLACKCAT_TENSORS_NEURAL_NETWORKS_LAYERS_MAX_POOLING_H_ 9 #define BLACKCAT_TENSORS_NEURAL_NETWORKS_LAYERS_MAX_POOLING_H_ 16 template<
class SystemTag,
class ValueType>
19 Max_Pooling<SystemTag, ValueType>,
20 Tensor_Descriptor<ValueType, SystemTag, Integer<3>>>
60 m_krnl_dims(krnl_dims),
62 m_strides(strides ==
Dim<2>{-1,-1} ? krnl_dims : strides)
64 Dim<2> img_hw = img_dims.template subdim<0,2>();
67 BC_ASSERT((img_dims > 0).all(),
"Max_Pooling img_dims must be greater than 0");
68 BC_ASSERT((m_krnl_dims > 0).all(),
"Max_Pooling krnl_dims must be greater than 0");
69 BC_ASSERT((m_strides > 0).all(),
"Max_Pooling strides must be greater than 0");
70 BC_ASSERT((m_padding >= 0).all(),
"Max_Pooling krnl_dims must be greater than 0 or equal to 0");
84 bc::streams::select_on_get_stream(image),
85 image.expression_template(),
106 bc::streams::select_on_get_stream(image),
107 image.expression_template(),
108 pooled_image.expression_template(),
109 mask.expression_template(),
117 template<
class Image,
class Delta>
120 const Delta& pooled_delta,
127 bc::streams::select_on_get_stream(image),
140 template<
class ValueType,
class SystemTag>
149 img_dims, krnl_dims, padding, strides);
154 template<
class SystemTag>
156 SystemTag system_tag,
164 typename SystemTag::default_floating_point_type>(
165 img_dims, krnl_dims, padding, strides);
175 typename BLACKCAT_DEFAULT_SYSTEM_T::default_floating_point_type>(
176 img_dims, krnl_dims, padding, strides);
Max_Pooling(Dim< 3 > img_dims, Dim< 2 > krnl_dims={3, 3}, Dim< 2 > padding={0, 0}, Dim< 2 > strides={-1,-1})
Definition: max_pooling.h:54
self_type & zero()
Definition: tensor_base.h:13
std::true_type defines_single_predict
Definition: max_pooling.h:35
Definition: constexpr_int.h:14
Definition: layer_base.h:86
#define BLACKCAT_DEFAULT_SYSTEM_T
Definition: common.h:49
A Dictionary designed to store any type using the 'store' and 'load' functions.
Definition: layer_cache.h:46
Definition: layer_cache.h:33
std::true_type greedy_evaluate_delta
Definition: max_pooling.h:33
auto get_batched_input_shape() const
Definition: layer_base.h:144
auto get_batched_output_shape() const
Definition: layer_base.h:145
std::true_type requires_extra_cache
Definition: max_pooling.h:34
Max_Pooling< SystemTag, ValueType > max_pooling(SystemTag system_tag, Dim< 3 > img_dims, Dim< 2 > krnl_dims={3, 3}, Dim< 2 > padding={0, 0}, Dim< 2 > strides={-1,-1})
Definition: max_pooling.h:141
auto single_predict(const Image &image, Cache &cache)
Definition: max_pooling.h:97
auto back_propagation(const Image &image, const Delta &pooled_delta, Cache &cache)
Definition: max_pooling.h:118
auto & store(key_type< K, V, cache_key_type::inherit > key, U &&expression)
Definition: layer_cache.h:104
Layer_Base< self_type, input_tensor_descriptor_t > parent_type
Definition: max_pooling.h:30
auto & load(key_type< K, V, cache_key_type::inherit > key, int t_modifier=0) const
Definition: layer_cache.h:80
output_shape_type m_output_shape
Definition: layer_base.h:118
BCINLINE const Derived & expression_template() const
Definition: expression_template_base.h:22
void max_pooling_forward(Stream stream, Image image, ImageOut out, Indexes mask, Dim< 2 > krnl_shape, Dim< 2 > padding=Dim< 2 >().fill(0), Dim< 2 > strides={-1,-1})
Definition: functions.h:19
SystemTag system_tag
Definition: max_pooling.h:27
#define BC_ASSERT(condition, message)
Definition: common.h:185
virtual output_shape_type get_output_shape() const
Definition: layer_base.h:141
Definition: max_pooling.h:17
ValueType value_type
Definition: max_pooling.h:28
BCINLINE auto concat(Ints... value) const
Definition: dim.h:105
void max_pooling_backward(Stream stream, Image image, ImageOut delta, Indexes mask, Dim< 2 > krnl_shape, Dim< 2 > padding=Dim< 2 >().fill(0), Dim< 2 > strides=Dim< 2 >().fill(-1))
Definition: functions.h:59
The Evaluator determines if an expression needs to be greedily optimized.
Definition: algorithms.h:22
Definition: recycle_allocator.h:57
auto forward_propagation(const Image &image, Cache &cache)
Definition: max_pooling.h:75