return ML_ERROR_INVALID_PARAMETER;
}
+ if (input_dim.size() != 1) {
+ ml_loge("[Pooling2D] pooling layer only accepts number of one layer");
+ return ML_ERROR_INVALID_PARAMETER;
+ }
+
TensorDim &in_dim = input_dim[0];
TensorDim &out_dim = output_dim[0];
if (pooling_type == PoolingType::global_max ||
pooling_type == PoolingType::global_average) {
- if (pool_size[0] != in_dim.height() || pool_size[1] != in_dim.width()) {
- ml_logw(
+ if (pool_size[0] != 0 || pool_size[1] != 0) {
+ ml_loge(
"[Pooling2D] global_max, global_average does not accept pool size");
- pool_size[0] = in_dim.height();
- pool_size[1] = in_dim.width();
+ return ML_ERROR_INVALID_PARAMETER;
}
+ pool_size[0] = in_dim.height();
+ pool_size[1] = in_dim.width();
if (padding[0] != 0 || padding[1] != 0) {
- ml_logw("[Pooling2D] global_max, global_average does not accept padding");
- padding[0] = 0;
- padding[1] = 0;
+ ml_loge("[Pooling2D] global_max, global_average does not accept padding");
+ return ML_ERROR_INVALID_PARAMETER;
}
if (stride[0] != 1 || stride[1] != 1) {
- ml_logw("[Pooling2D] global_max, global_average does not accept stride");
- stride[0] = 1;
- stride[1] = 1;
+ ml_loge("[Pooling2D] global_max, global_average does not accept stride");
+ return ML_ERROR_INVALID_PARAMETER;
}
}
std::array<unsigned int, POOLING2D_DIM> padding;
std::vector<int>
max_idx; /**< in case of max pool, idx that points to the first max item
- in case of avearge pol, effective average counter */
+ in case of avearge pol, effective average counter
+ effective average counter is number of patches actually
+ counted into when calculating the average
+ // clang-format off
+ eg) pooling of below
+ x x x
+ x 3 3
+ x 3 3
+ = 12 / 4 = 3
+ // clang-format on
+ */
std::vector<std::vector<int>> max_idx_global;
PoolingType pooling_type;
void addOptimizerVariable(std::vector<nntrainer::Weight> ¶ms) override {}
- void setProperty(const PropertyType type, const std::string &value = "") override {}
+ void setProperty(const PropertyType type,
+ const std::string &value = "") override {}
void checkValidation() const override {}
int setProperty(std::vector<std::string> values) override { return 1; }
- void setProperty(const PropertyType type, const std::string &value = "") override {}
+ void setProperty(const PropertyType type,
+ const std::string &value = "") override {}
int checkValidation() override { return 1; }
TEST_F(nntrainer_Pooling2DLayer, backwarding_03_p) {
resetLayer();
setInputDim("2:5:5");
- setProperty("pool_size=2,2 | stride=1,1 | padding=0,0 | pooling=global_max");
+ setProperty("pooling=global_max");
initialize();
allocateMemory();
TEST_F(nntrainer_Pooling2DLayer, backwarding_04_p) {
setInputDim("2:5:5");
- setProperty(
- "pool_size=2,2 | stride=1,1 | padding=0,0 | pooling=global_average");
+ setProperty("pooling=global_average");
initialize();
allocateMemory();
loadFile("tc_pooling2d_1.in", in);