Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a one-to-many test case in examples #298

Open
rcoreilly opened this issue Aug 21, 2023 · 0 comments
Open

add a one-to-many test case in examples #298

rcoreilly opened this issue Aug 21, 2023 · 0 comments

Comments

@rcoreilly
Copy link
Member

useful for testing noise params etc. test case was in obelisk -- very out of date -- easier to maintain within axon when doing mass updates. start with ra25 and add these specializations:

// ConfigPats used to configure patterns
func (ss *Sim) ConfigPats() {
	dt := ss.Pats
	dt.SetMetaData("name", "TrainPats")
	dt.SetMetaData("desc", "Training patterns")
	sch := etable.Schema{
		{Name: "Name", Type: etensor.STRING, CellShape: nil, DimNames: nil},
		{Name: "Input", Type: etensor.FLOAT32, CellShape: []int{5, 5}, DimNames: []string{"Y", "X"}},
		{Name: "Output", Type: etensor.FLOAT32, CellShape: []int{5, 5}, DimNames: []string{"Y", "X"}},
	}
	dt.SetFromSchema(sch, ss.NInputs*ss.NOutputs)

	patgen.PermutedBinaryMinDiff(dt.Cols[1].(*etensor.Float32), 6, 1, 0, 3)
	patgen.PermutedBinaryMinDiff(dt.Cols[2].(*etensor.Float32), 6, 1, 0, 3)
	for i := 0; i < ss.NInputs; i++ {
		for j := 0; j < ss.NOutputs; j++ {
			dt.SetCellTensor("Input", i*ss.NOutputs+j, dt.CellTensor("Input", i*ss.NOutputs))
			dt.SetCellString("Name", i*ss.NOutputs+j, fmt.Sprintf("%d", i))
		}
	}
	dt.SaveCSV("random_5x5_25_gen.tsv", etable.Tab, etable.Headers)
}
// TrialStats computes the trial-level statistics.
// Aggregation is done directly from log data.
func (ss *Sim) TrialStats() {
	out := ss.Net.LayerByName("Output").(axon.AxonLayer).AsAxon()

	ss.Stats.SetFloat("TrlCorSim", float64(out.Vals[0].CorSim.Cor))
	ss.Stats.SetFloat("TrlUnitErr", out.PctUnitErr(&ss.Context)[0])

	_, cor, cnm := ss.Stats.ClosestPat(ss.Net, "Output", "ActM", 0, ss.Pats, "Output", "Name")

	//For each name, record map of closest rows that are predicted
	//For each name, record rows associated with
	ss.Stats.SetString("TrlClosest", cnm)
	ss.Stats.SetFloat("TrlCorrel", float64(cor))
	ev := ss.Envs[ss.Context.Mode.String()].(*env.FixedTable)
	tnm := ev.TrialName.Cur
	if cnm == tnm {
		ss.Stats.SetFloat("TrlErr", 0)
	} else {
		ss.Stats.SetFloat("TrlErr", 1)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant