Advertisement

ND4J支持对INDArray的序列化和反序列化操作

阅读量:
复制代码
    import org.nd4j.linalg.api.ndarray.INDArray;
    import org.nd4j.linalg.factory.Nd4j;
    import org.nd4j.serde.binary.BinarySerde;
    
    import java.io.*;
    import java.nio.ByteBuffer;
    
    INDArray arrWrite = Nd4j.linspace(1,10,10);
    INDArray arrRead;
    
    //1. Binary format  二进制格式
    //   Close the streams manually or use try with resources.
    try (DataOutputStream sWrite = new DataOutputStream(new FileOutputStream(new File("tmp.bin")))) {
    Nd4j.write(arrWrite, sWrite);
    }
    
    try (DataInputStream sRead = new DataInputStream(new FileInputStream(new File

全部评论 (0)

还没有任何评论哟~