Java Code Examples for org.datavec.api.transform.ColumnType#NDArray

The following examples show how to use org.datavec.api.transform.ColumnType#NDArray . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NDArrayColumnsMathOpTransform.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Override
protected ColumnMetaData derivedColumnMetaData(String newColumnName, Schema inputSchema) {
    //Check types

    for (int i = 0; i < columns.length; i++) {
        if (inputSchema.getMetaData(columns[i]).getColumnType() != ColumnType.NDArray) {
            throw new RuntimeException("Column " + columns[i] + " is not an NDArray column");
        }
    }

    //Check shapes
    NDArrayMetaData meta = (NDArrayMetaData) inputSchema.getMetaData(columns[0]);
    for (int i = 1; i < columns.length; i++) {
        NDArrayMetaData meta2 = (NDArrayMetaData) inputSchema.getMetaData(columns[i]);
        if (!Arrays.equals(meta.getShape(), meta2.getShape())) {
            throw new UnsupportedOperationException(
                            "Cannot perform NDArray operation on columns with different shapes: " + "Columns \""
                                            + columns[0] + "\" and \"" + columns[i] + "\" have shapes: "
                                            + Arrays.toString(meta.getShape()) + " and "
                                            + Arrays.toString(meta2.getShape()));
        }
    }

    return new NDArrayMetaData(newColumnName, meta.getShape());
}
 
Example 2
Source File: NDArrayColumnsMathOpTransform.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
protected ColumnMetaData derivedColumnMetaData(String newColumnName, Schema inputSchema) {
    //Check types

    for (int i = 0; i < columns.length; i++) {
        if (inputSchema.getMetaData(columns[i]).getColumnType() != ColumnType.NDArray) {
            throw new RuntimeException("Column " + columns[i] + " is not an NDArray column");
        }
    }

    //Check shapes
    NDArrayMetaData meta = (NDArrayMetaData) inputSchema.getMetaData(columns[0]);
    for (int i = 1; i < columns.length; i++) {
        NDArrayMetaData meta2 = (NDArrayMetaData) inputSchema.getMetaData(columns[i]);
        if (!Arrays.equals(meta.getShape(), meta2.getShape())) {
            throw new UnsupportedOperationException(
                            "Cannot perform NDArray operation on columns with different shapes: " + "Columns \""
                                            + columns[0] + "\" and \"" + columns[i] + "\" have shapes: "
                                            + Arrays.toString(meta.getShape()) + " and "
                                            + Arrays.toString(meta2.getShape()));
        }
    }

    return new NDArrayMetaData(newColumnName, meta.getShape());
}
 
Example 3
Source File: NDArrayMetaData.java    From DataVec with Apache License 2.0 4 votes vote down vote up
@Override
public ColumnType getColumnType() {
    return ColumnType.NDArray;
}
 
Example 4
Source File: NDArrayAnalysis.java    From DataVec with Apache License 2.0 4 votes vote down vote up
@Override
public ColumnType getColumnType() {
    return ColumnType.NDArray;
}
 
Example 5
Source File: NDArrayMetaData.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public ColumnType getColumnType() {
    return ColumnType.NDArray;
}
 
Example 6
Source File: NDArrayAnalysis.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public ColumnType getColumnType() {
    return ColumnType.NDArray;
}