提交 4b1bc681 编写于 作者: H hedaoyuan

Fix comments of slice_projection, and add unit test of SliceProjection.

上级 0cca0fcf
......@@ -152,6 +152,26 @@ TEST(Projection, identity) {
}
}
TEST(Projection, slice) {
ProjectionConfig conf;
conf.set_type("slice");
conf.set_input_size(100);
SliceConfig& slice1 = *conf.add_slices();
slice1.set_start(10);
slice1.set_end(20);
SliceConfig& slice2 = *conf.add_slices();
slice2.set_start(50);
slice2.set_end(70);
conf.set_output_size(30);
for (auto useGpu : {false, true}) {
testProjectionGrad(conf,
INPUT_DATA,
/* parameterSize */ 0,
/* batchSize */ 100,
useGpu);
}
}
TEST(Projection, scaling) {
ProjectionConfig conf;
conf.set_type("scaling");
......
......@@ -539,11 +539,11 @@ def identity_projection(input, offset=None, size=None):
def slice_projection(input, slices):
"""
slice_projection can get multiple outputs, and each output is a slice
of the input.
slice_projection can slice the input value into multiple parts,
and then select some of them to merge into a new output.
.. math::
output[i] = input.slice(slices[i])
output = [input.slices()]
The example usage is:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册