~/bend-docscommunity

tensor_model.bend checks

raw source on the hub · import stelliferous@0.0.3.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.

4 imports
import Base
import ./tensor.bend as Tensors
import ./tensor_layout.bend as Layout
import ./tensor_file.bend as Files

Types

type Store source · line 12 · raw

Type

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

Definitions

def Tensor source · line 8 · raw

Type

def Model source · line 18 · raw

@A:Type -> Type

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

def Model.pure source · line 21 · raw

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

def Model.next source · line 24 · raw

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

def Model.bind source · line 28 · raw

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

def missing source · line 31 · raw

@+name:String -> Tensor

def unavailable source · line 34 · raw

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

def passed source · line 38 · raw

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

def scan source · line 42 · raw

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

def taken source · line 51 · raw

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

def take source · line 59 · 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 62 · raw

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

def named_rest source · line 67 · 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 72 · 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 78 · raw

Model(List<&2, String>)

def keep source · line 81 · raw

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

def run source · line 84 · raw

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

def value source · line 87 · raw

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

def result source · line 92 · 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 95 · raw

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

def copied_entry source · line 99 · raw

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

def copy source · line 104 · raw

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

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

def entry source · line 112 · raw

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

def load_each source · line 115 · raw

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

def unlisted source · line 127 · raw

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

def named source · line 130 · raw

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

def listed source · line 135 · raw

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

def opened source · line 141 · raw

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

def load source · line 150 · 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 157 · raw

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

def lines source · line 161 · raw

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

def save_each source · line 167 · raw

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

def listing source · line 177 · raw

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

def save_listed source · line 185 · raw

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

def save source · line 193 · raw

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

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