use of com.alibaba.alink.operator.batch.dataproc.VectorToTensorBatchOp in project Alink by alibaba.
the class VectorToTensorMapperTest method testOp.
@Test
public void testOp() throws Exception {
final DoubleTensor tensor = DoubleTensor.of(TensorUtil.getTensor("FLOAT#6#0.0 0.1 1.0 1.1 2.0 2.1 "));
final FloatTensor expect = FloatTensor.of(tensor.reshape(new Shape(2L, 3L)));
Row[] rows = new Row[] { Row.of(tensor.toVector()) };
MemSourceBatchOp memSourceBatchOp = new MemSourceBatchOp(rows, new String[] { "vec" });
memSourceBatchOp.link(new VectorToTensorBatchOp().setSelectedCol("vec").setTensorShape(2, 3).setTensorDataType("float")).lazyCollect(new Consumer<List<Row>>() {
@Override
public void accept(List<Row> rows) {
Assert.assertEquals(expect, TensorUtil.getTensor(rows.get(0).getField(0)));
}
});
BatchOperator.execute();
}
Aggregations