本文整理了Java中org.nd4j.linalg.factory.Nd4j.writeComplex()
方法的一些代码示例,展示了Nd4j.writeComplex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.writeComplex()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:writeComplex
[英]Write an ndarray to the specified outputs tream
[中]将数据数组写入指定的输出
代码示例来源:origin: deeplearning4j/nd4j
/**
* Convert an ndarray to a blob
*
* @param toConvert the complex ndarray to convert
* @return the converted complex ndarray
*/
@Override
public Blob convert(IComplexNDArray toConvert) throws IOException, SQLException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
Nd4j.writeComplex(toConvert, dos);
byte[] bytes = bos.toByteArray();
Connection c = dataSource.getConnection();
Blob b = c.createBlob();
b.setBytes(1, bytes);
return b;
}
代码示例来源:origin: deeplearning4j/nd4j
private void doSave(INDArray save, String id) throws SQLException, IOException {
Connection c = dataSource.getConnection();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
if (save instanceof IComplexNDArray) {
IComplexNDArray c2 = (IComplexNDArray) save;
Nd4j.writeComplex(c2, dos);
} else {
BinarySerde.writeArrayToOutputStream(save,bos);
}
byte[] bytes = bos.toByteArray();
PreparedStatement preparedStatement = c.prepareStatement(insertStatement());
preparedStatement.setString(1, id);
preparedStatement.setBytes(2, bytes);
preparedStatement.executeUpdate();
}
代码示例来源:origin: org.nd4j/nd4j-x86
/**
* Write a complex ndarray to an output stream
*
* @param out the ndarray to write
* @param to the output stream to write to
*/
@Override
public void writeComplex(IComplexNDArray out, OutputStream to) throws IOException {
Nd4j.writeComplex(out, new DataOutputStream(to));
}
}
代码示例来源:origin: org.nd4j/nd4j-jdbc-api
/**
* Convert an ndarray to a blob
*
* @param toConvert the complex ndarray to convert
* @return the converted complex ndarray
*/
@Override
public Blob convert(IComplexNDArray toConvert) throws IOException, SQLException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
Nd4j.writeComplex(toConvert, dos);
byte[] bytes = bos.toByteArray();
Connection c = dataSource.getConnection();
Blob b = c.createBlob();
b.setBytes(1, bytes);
c.close();
return b;
}
代码示例来源:origin: org.nd4j/nd4j-jdbc-api
private void doSave(INDArray save, String id) throws SQLException, IOException {
Connection c = dataSource.getConnection();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
if (save instanceof IComplexNDArray) {
IComplexNDArray c2 = (IComplexNDArray) save;
Nd4j.writeComplex(c2, dos);
} else
Nd4j.write(save, dos);
byte[] bytes = bos.toByteArray();
PreparedStatement preparedStatement = c.prepareStatement(insertStatement());
preparedStatement.setString(1, id);
preparedStatement.setBytes(2, bytes);
preparedStatement.executeUpdate();
preparedStatement.close();
c.close();
}
内容来源于网络,如有侵权,请联系作者删除!