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

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

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

Nd4j.readNumpy介绍

[英]Read line via input streams
[中]通过输入流读取行

代码示例

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

  1. /**
  2. * Read line via input streams
  3. *
  4. * @param filePath the input stream ndarray
  5. * @return the read txt method
  6. */
  7. public static INDArray readNumpy(String filePath) throws IOException {
  8. return readNumpy(filePath, "\t");
  9. }

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

  1. /**
  2. * Read line via input streams
  3. *
  4. * @param filePath the input stream ndarray
  5. * @param split the split separator
  6. * @return the read txt method
  7. */
  8. public static INDArray readNumpy(String filePath, String split) throws IOException {
  9. return readNumpy(new FileInputStream(filePath), split);
  10. }

代码示例来源:origin: deeplearning4j/dl4j-examples

  1. readFromText = Nd4j.readNumpy(makeResourcePath("/numpy_cheatsheet/file.txt"));
  2. print("Read from text", readFromText);
  3. } catch (IOException e) {
  4. readFromCSV = Nd4j.readNumpy(makeResourcePath("/numpy_cheatsheet/file.csv"), ",");
  5. print("Read from csv", readFromCSV);
  6. } catch (IOException e) {

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

  1. /**
  2. * Read line via input streams
  3. *
  4. * @param filePath the input stream ndarray
  5. * @return the read txt method
  6. */
  7. public static INDArray readNumpy(String filePath) throws IOException {
  8. return readNumpy(filePath, "\t");
  9. }

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

  1. /**
  2. * Read line via input streams
  3. *
  4. * @param filePath the input stream ndarray
  5. * @param split the split separator
  6. * @return the read txt method
  7. */
  8. public static INDArray readNumpy(String filePath, String split) throws IOException {
  9. return readNumpy(new FileInputStream(filePath), split);
  10. }

代码示例来源:origin: sjsdfg/dl4j-tutorials

  1. protected static Map<String, INDArray> readPlaceholdersAndPredictions() throws IOException {
  2. String[] toReadList = {"input_a", "input_b", "prediction_a", "prediction_b"};
  3. Map<String, INDArray> arraysFromPython = new HashMap<>();
  4. for (int i = 0; i < toReadList.length; i++) {
  5. String varShapePath = new ClassPathResource(BASE_DIR + "/" + toReadList[i] + ".shape").getFile().getPath();
  6. String varValuePath = new ClassPathResource(BASE_DIR + "/" + toReadList[i] + ".csv").getFile().getPath();
  7. int[] varShape = Nd4j.readNumpy(varShapePath, ",").data().asInt();
  8. float[] varContents = Nd4j.readNumpy(varValuePath).data().asFloat();
  9. arraysFromPython.put(toReadList[i], Nd4j.create(varContents).reshape(varShape));
  10. }
  11. return arraysFromPython;
  12. }
  13. }

相关文章