Documentation ¶
Overview ¶
Package patgen contains functions that generate patterns, typically based on various constrained-forms of random patterns
Index ¶
- Variables
- func AddVocabClone(mp Vocab, name string, copyFrom string) (*etensor.Float32, error)
- func AddVocabDrift(mp Vocab, name string, rows int, pctDrift float32, copyFrom string, ...) (*etensor.Float32, error)
- func AddVocabEmpty(mp Vocab, name string, rows, poolY, poolX int) (*etensor.Float32, error)
- func AddVocabPermutedBinary(mp Vocab, name string, rows, poolY, poolX int, pctAct, minPctDiff float32) (*etensor.Float32, error)
- func AddVocabRepeat(mp Vocab, name string, rows int, copyFrom string, copyRow int) (*etensor.Float32, error)
- func FlipBits(tsr etensor.Tensor, nOff, nOn int, onVal, offVal float64)
- func FlipBitsRows(tsr etensor.Tensor, nOff, nOn int, onVal, offVal float64)
- func InitPats(dt *etable.Table, name, desc, inputName, outputName string, ...)
- func MixPats(dt *etable.Table, mp Vocab, colName string, poolSource []string) error
- func MixPatsN(dt *etable.Table, mp Vocab, colName string, poolSource []string, ...) error
- func NFmPct(pct float32, n int) int
- func NOnInTensor(trow *etensor.Float32) int
- func PctActInTensor(trow *etensor.Float32) float32
- func PermutedBinary(tsr etensor.Tensor, nOn int, onVal, offVal float64)
- func PermutedBinaryMinDiff(tsr *etensor.Float32, nOn int, onVal, offVal float32, minDiff int) error
- func PermutedBinaryRows(tsr etensor.Tensor, nOn int, onVal, offVal float64)
- func ReshapeCpp(dt *etable.Table)
- func ReshapeCppFile(dt *etable.Table, fname, fixnm string)
- func RowVsPrevDist32(tsr *etensor.Float32, row int, fun metric.Func32) (min, max float32)
- func Shuffle(dt *etable.Table, rows []int, colNames []string, colIndependent bool)
- func VocabConcat(mp Vocab, newPool string, frmPools []string) error
- func VocabShuffle(mp Vocab, shufflePools []string)
- func VocabSlice(mp Vocab, frmPool string, newPools []string, sliceOffs []int) error
- type Vocab
Constants ¶
This section is empty.
Variables ¶
var MinDiffPrintIters = false
MinDiffPrintIters set this to true to see the iteration stats for PermutedBinaryMinDiff -- for large, long-running cases.
Functions ¶
func AddVocabClone ¶ added in v1.0.1
AddVocabClone clones an existing pool in the vocabulary to make a new one.
func AddVocabDrift ¶ added in v1.0.1
func AddVocabDrift(mp Vocab, name string, rows int, pctDrift float32, copyFrom string, copyRow int) (*etensor.Float32, error)
AddVocabDrift adds a row-by-row drifting pool to the vocabulary, starting from the given row in existing vocabulary item (which becomes starting row in this one -- drift starts in second row). The current row patterns are generated by taking the previous row pattern and flipping pctDrift percent of active bits (min of 1 bit).
func AddVocabEmpty ¶ added in v1.0.1
AddVocabEmpty adds an empty pool to the vocabulary. This can be used to make test cases with missing pools.
func AddVocabPermutedBinary ¶ added in v1.0.1
func AddVocabPermutedBinary(mp Vocab, name string, rows, poolY, poolX int, pctAct, minPctDiff float32) (*etensor.Float32, error)
AddVocabPermutedBinary adds a permuted binary pool to the vocabulary. This is a good source of random patterns with no systematic similarity. pctAct = proportion (0-1) bits turned on for a pool. minPctDiff = proportion of pctAct (0-1) for minimum difference between patterns -- e.g., .5 = each pattern must have half of its bits different from each other. This constraint can be hard to meet depending on the number of rows, amount of activity, and minPctDiff level -- an error will be returned and printed if it cannot be satisfied in a reasonable amount of time.
func AddVocabRepeat ¶ added in v1.0.1
func AddVocabRepeat(mp Vocab, name string, rows int, copyFrom string, copyRow int) (*etensor.Float32, error)
AddVocabRepeat adds a repeated pool to the vocabulary, copying from given row in existing vocabulary item .
func FlipBits ¶ added in v1.0.1
FlipBits turns nOff bits that are currently On to Off and nOn bits that are currently Off to On, using permuted lists.
func FlipBitsRows ¶ added in v1.0.1
FlipBitsRows turns nOff bits that are currently On to Off and nOn bits that are currently Off to On, using permuted lists. Iterates over the outer-most tensor dimension as rows.
func InitPats ¶ added in v1.0.1
func InitPats(dt *etable.Table, name, desc, inputName, outputName string, listSize, ySize, xSize, poolY, poolX int)
InitPats initiates patterns to be used in MixPats
func MixPats ¶ added in v1.0.1
MixPats mixes patterns using first listSize rows in the vocabulary map poolSource order: left right, bottom up
func MixPatsN ¶ added in v1.1.5
func MixPatsN(dt *etable.Table, mp Vocab, colName string, poolSource []string, targRow, vocabStart, vocabN int) error
MixPatsN mixes patterns using specified startVocab and vocabN numbers of vocabulary patterns, inserting starting at specified targRow in table. poolSource order: left right, bottom up
func NFmPct ¶ added in v1.0.1
NFmPct returns the number of bits for given pct (proportion 0-1), relative to total n. uses math.Round.
func NOnInTensor ¶ added in v1.0.1
NOnInTensor returns the number of bits active in given tensor
func PctActInTensor ¶ added in v1.0.1
PctActInTensor returns the percent activity in given tensor (NOn / size)
func PermutedBinary ¶
PermutedBinary sets the given tensor to contain nOn onVal values and the remainder are offVal values, using a permuted order of tensor elements (i.e., randomly shuffled or permuted).
func PermutedBinaryMinDiff ¶ added in v1.0.1
PermutedBinaryMinDiff treats the tensor as a column of rows as in a etable.Table and sets each row to contain nOn onVal values and the remainder are offVal values, using a permuted order of tensor elements (i.e., randomly shuffled or permuted). This version ensures that all patterns have at least a given minimum distance from each other, expressed using minDiff = number of bits that must be different (can't be > nOn). If the mindiff constraint cannot be met within a reasonable number of iterations, then an error is returned.
func PermutedBinaryRows ¶
PermutedBinaryRows treats the tensor as a column of rows as in a etable.Table and sets each row to contain nOn onVal values and the remainder are offVal values, using a permuted order of tensor elements (i.e., randomly shuffled or permuted).
func ReshapeCpp ¶ added in v1.0.0
ReshapeCpp fixes C++ emergent table shape which is reversed from Go. it switches the dimension order in the given table, for all columns that are float 2D or 4D columns -- assumes these are layer patterns and names dimensions accordingly.
func ReshapeCppFile ¶ added in v1.0.0
ReshapeCppFile fixes C++ emergent table shape which is reversed from Go. It loads file from fname and saves to fixnm
func RowVsPrevDist32 ¶ added in v1.0.1
RowVsPrevDist32 returns the minimum and maximum distance between the given row in tensor and all previous rows. Row must be >= 1 and < total rows. (outer-most dimension is row, as in columns of etable.Table).
func Shuffle ¶ added in v1.0.1
Shuffle shuffles rows in specified columns in the table independently
func VocabConcat ¶ added in v1.0.1
VocabConcat contatenates several pools in the vocabulary and store it into newPool (could be one of the previous pools).
func VocabShuffle ¶ added in v1.0.1
VocabShuffle shuffles a pool in the vocabulary on its first dimension (row).