Java 类名:com.alibaba.alink.operator.batch.dataproc.TensorToVectorBatchOp
Python 类名:TensorToVectorBatchOp
转换张量类型为向量类型。
名称 | 中文名称 | 描述 | 类型 | 是否必须? | 取值范围 | 默认值 |
---|---|---|---|---|---|---|
selectedCol | 选中的列名 | 计算列对应的列名 | String | ✓ | 所选列类型为 [DOUBLE_TENSOR, FLOAT_TENSOR, INT_TENSOR, LONG_TENSOR] | |
convertMethod | 转换方法 | 张量转换为向量的方法,可取 flatten, sum, mean, max, min. | String | “FLATTEN”, “SUM”, “MEAN”, “MAX”, “MIN” | “FLATTEN” | |
outputCol | 输出结果列 | 输出结果列列名,可选,默认null | String | null | ||
reservedCols | 算法保留列名 | 算法保留列 | String[] | null | ||
numThreads | 组件多线程线程个数 | 组件多线程线程个数 | Integer | 1 |
from pyalink.alink import * import pandas as pd useLocalEnv(1) df_data = pd.DataFrame([ ['DOUBLE#6#0.0 0.1 1.0 1.1 2.0 2.1'] ]) batch_data = BatchOperator.fromDataframe(df_data, schemaStr = 'tensor string') batch_data.link(TensorToVectorBatchOp().setSelectedCol("tensor")).print()
import org.apache.flink.types.Row; import com.alibaba.alink.operator.batch.source.MemSourceBatchOp; import org.junit.Test; import java.util.Collections; import java.util.List; public class TensorToVectorBatchOpTest { @Test public void testTensorToVectorBatchOp() throws Exception { List <Row> data = Collections.singletonList(Row.of("DOUBLE#6#0.0 0.1 1.0 1.1 2.0 2.1")); MemSourceBatchOp memSourceBatchOp = new MemSourceBatchOp(data, "tensor string"); memSourceBatchOp .link( new TensorToVectorBatchOp() .setSelectedCol("tensor") ) .print(); } }
tensor |
---|
0.0 0.1 1.0 1.1 2.0 2.1 |