def f_pool(self, x, spec, in_dim): layer_type, dims = spec num_filters = in_dim[0] if "globalmeanpool" == layer_type: y, output_size = global_meanpool_2d(x, num_filters) # scale the variance to match normal conv layers with xavier init y = y * np.float32(in_dim[-1]) * np.float32(np.sqrt(3)) else: assert dims[0] != 1 or dims[1] != 1 y, output_size = maxpool_2d(x, in_dim, poolsize=(dims[1], dims[1]), poolstride=(dims[0], dims[0])) return y, output_size