Esempio n. 1
0
 def load_block_graph(self, suffix):
     bhash = self.hash
     prefix = self.chain.block_path / bhash[-2] / bhash[-1]
     datafile = prefix / f"{self.number}_{bhash}_{suffix}.ssb"
     if not datafile.exists():
         return maximal_matrix(UINT64)
     return Matrix.from_binfile(bytes(datafile))
Esempio n. 2
0
def load_layer(neurons, dest, i):
    fname = "{}/neuron{}/n{}-l{}.{}"
    binfile = fname.format(dest, neurons, neurons, str(i + 1), "ssb")
    if Path(binfile).exists():
        return Matrix.from_binfile(binfile.encode("ascii"))
    l = Path(fname.format(dest, neurons, neurons, str(i + 1), "tsv"))
    with l.open() as f:
        m = Matrix.from_tsv(f, FP32, neurons, neurons)
        m.to_binfile(binfile.encode("ascii"))
        return m
Esempio n. 3
0
def load_images(neurons, dest):
    fname = "{}/sparse-images-{}.{}"
    binfile = fname.format(dest, neurons, "ssb")
    if Path(binfile).exists():
        return Matrix.from_binfile(binfile.encode("ascii"))
    images = Path(fname.format(dest, neurons, "tsv"))
    with images.open() as i:
        m = Matrix.from_tsv(i, FP32, NFEATURES, neurons)
        m.to_binfile(binfile.encode("ascii"))
        return m