~/bend-docscommunity

tensor_model.bend checks

raw source on the hub · import stelliferous@0.0.4.0/tensor_model.bend as Tensor_model

Models: a step computes with tensors it takes by name from a store, so a network reads as one step after another and its weights are loaded once.

5 imports
import Base
import ./tensor.bend as Tensors
import ./tensor_grid.bend as Grid
import ./tensor_file.bend as Files
import ./tensor_tiled.bend as Tiled

Types

type Store source · line 25 · raw

Type

A store that could not be loaded keeps its problem, and every take reports it.

Definitions

def Tensor source · line 10 · raw

Type

The store holds the tensors in their tiled form: a file read tiles once.

def stored_along source · line 16 · raw

@single:Bool -> @tensor:0xa2af805348d03b11eb853850859654f6/tensor_file.Tensor -> Tensor

A stored tensor is laid out as parameters are read: weights [outputs, inputs,...] with the lanes along the outputs and the groups outermost, as convolutions and matrix products read them.

def stored source · line 21 · raw

@tensor:0xa2af805348d03b11eb853850859654f6/tensor_file.Tensor -> Tensor

def Model source · line 31 · raw

@A:Type -> Type

A step: given the store, a value and the store that remains.

def Model.pure source · line 34 · raw

@-A:Type -> @value:A -> Model(A)

def Model.next source · line 37 · raw

@-A:Type -> @-B:Type -> @pair:Pair(A, Store) -> @next:(@_:A -> Model(B)) -> Pair(B, Store)

def Model.bind source · line 41 · raw

@-A:Type -> @-B:Type -> @step:Model(A) -> @next:(@_:A -> Model(B)) -> Model(B)

def missing source · line 44 · raw

@+name:String -> Tensor

def unavailable source · line 47 · raw

@problem:0xa2af805348d03b11eb853850859654f6/tensor.Problem -> Tensor

def passed source · line 51 · raw

@name:String -> @tensor:Tensor -> @pair:Pair(Tensor, Store) -> Pair(Tensor, Store)

def scan source · line 55 · raw

@rest:Store -> @same:Bool -> @+name:String -> @tensor:Tensor -> @+wanted:String -> Pair(Tensor, Store)

def taken source · line 64 · raw

@store:Store -> @+wanted:String -> Pair(Tensor, Store)

def take source · line 72 · raw

@+name:String -> Model(Tensor)

The tensor of that name leaves the store. A name that is not there gives a failed tensor.

def kept source · line 75 · raw

@+name:String -> @pair:Pair(Tensor, Tensor) -> @store:Store -> Pair(Tensor, Store)

def named_rest source · line 80 · raw

@+name:String -> @tensor:Tensor -> @pair:Pair(List<&2, String>, Store) -> Pair(List<&2, String>, Store)

Puts a copy under the name, for a later take, and gives the tensor back.

def names source · line 85 · raw

@store:Store -> Pair(List<&2, String>, Store)

The names in the store, in its order, and the store unchanged.

def listed_names source · line 91 · raw

Model(List<&2, String>)

def keep source · line 94 · raw

@+name:String -> @tensor:Tensor -> Model(Tensor)

def run source · line 97 · raw

@-A:Type -> @step:Model(A) -> @store:Store -> Pair(A, Store)

def value source · line 100 · raw

@-A:Type -> @pair:Pair(A, Store) -> A

def result source · line 105 · raw

@-A:Type -> @step:Model(A) -> @store:Store -> A

Runs the steps on the store and gives the result; what remains in the store is dropped.

def joined source · line 108 · raw

@+name:String -> @first:Tensor -> @second:Tensor -> @rest:Pair(Store, Store) -> Pair(Store, Store)

def copied_entry source · line 112 · raw

@+name:String -> @pair:Pair(Tensor, Tensor) -> @rest:Pair(Store, Store) -> Pair(Store, Store)

def copy source · line 117 · raw

@store:Store -> Pair(Store, Store)

Two stores with the same tensors, to run a model more than once.

def entry source · line 125 · raw

@+name:String -> @tensor:Tensor -> @store:Store -> Store

def load_each source · line 128 · raw

@names:List<&2, String> -> @+folder:String -> IO(Store)

def unlisted source · line 140 · raw

@+folder:String -> @detail:String -> Store

def named source · line 143 · raw

@text:Result<&1, &1, Pair(U32, String), String> -> @+folder:String -> IO(Store)

def listed source · line 148 · raw

@read:Pair(File, Result<&1, &1, Pair(U32, String), String>) -> @+folder:String -> IO(Store)

def opened source · line 154 · raw

@result:Result<&1, &1, Pair(U32, String), File> -> @+folder:String -> IO(Store)

def load source · line 163 · raw

@+folder:String -> IO(Store)

A folder whose names.txt cannot be read gives a store whose every take reports it.

def first source · line 170 · raw

@written:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> File

def lines source · line 174 · raw

@names:List<&2, String> -> String

def save_each source · line 180 · raw

@store:Store -> @+folder:String -> IO(Store)

def listing source · line 190 · raw

@result:Result<&1, &1, Pair(U32, String), File> -> @text:String -> IO(Unit)

def save_listed source · line 198 · raw

@pair:Pair(List<&2, String>, Store) -> @+folder:String -> IO(Store)

def save source · line 206 · raw

@+folder:String -> @store:Store -> IO(Store)

Gives the store back; a tensor that could not be written comes back failed.