org.nd4j.linalg.factory.Nd4j.writeComplex()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.nd4j.linalg.factory.Nd4j.writeComplex()方法的一些代码示例,展示了Nd4j.writeComplex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.writeComplex()方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:writeComplex

Nd4j.writeComplex介绍

[英]Write an ndarray to the specified outputs tream
[中]将数据数组写入指定的输出

代码示例

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Convert an ndarray to a blob
  3. *
  4. * @param toConvert the complex ndarray to convert
  5. * @return the converted complex ndarray
  6. */
  7. @Override
  8. public Blob convert(IComplexNDArray toConvert) throws IOException, SQLException {
  9. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  10. DataOutputStream dos = new DataOutputStream(bos);
  11. Nd4j.writeComplex(toConvert, dos);
  12. byte[] bytes = bos.toByteArray();
  13. Connection c = dataSource.getConnection();
  14. Blob b = c.createBlob();
  15. b.setBytes(1, bytes);
  16. return b;
  17. }

代码示例来源:origin: deeplearning4j/nd4j

  1. private void doSave(INDArray save, String id) throws SQLException, IOException {
  2. Connection c = dataSource.getConnection();
  3. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  4. DataOutputStream dos = new DataOutputStream(bos);
  5. if (save instanceof IComplexNDArray) {
  6. IComplexNDArray c2 = (IComplexNDArray) save;
  7. Nd4j.writeComplex(c2, dos);
  8. } else {
  9. BinarySerde.writeArrayToOutputStream(save,bos);
  10. }
  11. byte[] bytes = bos.toByteArray();
  12. PreparedStatement preparedStatement = c.prepareStatement(insertStatement());
  13. preparedStatement.setString(1, id);
  14. preparedStatement.setBytes(2, bytes);
  15. preparedStatement.executeUpdate();
  16. }

代码示例来源:origin: org.nd4j/nd4j-x86

  1. /**
  2. * Write a complex ndarray to an output stream
  3. *
  4. * @param out the ndarray to write
  5. * @param to the output stream to write to
  6. */
  7. @Override
  8. public void writeComplex(IComplexNDArray out, OutputStream to) throws IOException {
  9. Nd4j.writeComplex(out, new DataOutputStream(to));
  10. }
  11. }

代码示例来源:origin: org.nd4j/nd4j-jdbc-api

  1. /**
  2. * Convert an ndarray to a blob
  3. *
  4. * @param toConvert the complex ndarray to convert
  5. * @return the converted complex ndarray
  6. */
  7. @Override
  8. public Blob convert(IComplexNDArray toConvert) throws IOException, SQLException {
  9. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  10. DataOutputStream dos = new DataOutputStream(bos);
  11. Nd4j.writeComplex(toConvert, dos);
  12. byte[] bytes = bos.toByteArray();
  13. Connection c = dataSource.getConnection();
  14. Blob b = c.createBlob();
  15. b.setBytes(1, bytes);
  16. c.close();
  17. return b;
  18. }

代码示例来源:origin: org.nd4j/nd4j-jdbc-api

  1. private void doSave(INDArray save, String id) throws SQLException, IOException {
  2. Connection c = dataSource.getConnection();
  3. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  4. DataOutputStream dos = new DataOutputStream(bos);
  5. if (save instanceof IComplexNDArray) {
  6. IComplexNDArray c2 = (IComplexNDArray) save;
  7. Nd4j.writeComplex(c2, dos);
  8. } else
  9. Nd4j.write(save, dos);
  10. byte[] bytes = bos.toByteArray();
  11. PreparedStatement preparedStatement = c.prepareStatement(insertStatement());
  12. preparedStatement.setString(1, id);
  13. preparedStatement.setBytes(2, bytes);
  14. preparedStatement.executeUpdate();
  15. preparedStatement.close();
  16. c.close();
  17. }

相关文章