actrf

package
v2.0.0-dev0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Docs: GoDoc

Package actrf provides activation-based receptive field computation, otherwise known as reverse correlation or spike-triggered averaging. It simply computes the activation weighted average of other source patterns of activation -- i.e., sum(act * src) / sum(src) which then shows you the patterns of source activity for which a given unit was active.

The RF's are computed and stored in 4D tensors, where the outer 2D are the 2D pathway of the activation tensor (e.g., the activations of units in a layer), and the inner 2D are the 2D pathway of the source tensor.

This results in a nice standard RF plot that can be visualized in a tensor grid view.

There is a standard ActRF which is cumulative over a user-defined interval and a RunningAvg version which is computed online and continuously updated but is more susceptible to sampling bias (i.e., more sampled areas are more active in general), and a recency bias.

See objrec CCN sim for example usage.

Documentation

Overview

Package actrf provides activation-based receptive field computation, otherwise known as reverse correlation. It simply computes the activation weighted average of other *source* patterns of activation -- i.e., sum(act * src) / sum(src) which then shows you the patterns of source activity for which a given unit was active.

The RF's are computed and stored in 4D tensors, where the outer 2D are the 2D pathway of the activation tensor (e.g., the activations of units in a layer), and the inner 2D are the 2D pathway of the source tensor.

This results in a nice standard RF plot that can be visualized in a tensor grid view.

There is a standard ActRF which is cumulative over a user-defined interval and a RunningAvg version which is computed online and continuously updated but is more susceptible to sampling bias (i.e., more sampled areas are more active in general), and a recency bias.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunningAvg

func RunningAvg(out *tensor.Float32, act, src tensor.Tensor, tau float32)

RunningAvg computes a running-average activation-based receptive field for activities act relative to source activations src (the thing we're projecting rf onto) accumulating into output out, with time constant tau. act and src are projected into a 2D space (tensor.Projection2D* methods), and resulting out is 4D of act outer and src inner.

Types

type RF

type RF struct {

	// name of this RF -- used for management of multiple in RFs
	Name string

	// computed receptive field, as SumProd / SumSrc -- only after Avg has been called
	RF tensor.Float32 `display:"no-inline"`

	// unit normalized version of RF per source (inner 2D dimensions) -- good for display
	NormRF tensor.Float32 `display:"no-inline"`

	// normalized version of SumSrc -- sum of each point in the source -- good for viewing the completeness and uniformity of the sampling of the source space
	NormSrc tensor.Float32 `display:"no-inline"`

	// sum of the products of act * src
	SumProd tensor.Float32 `display:"no-inline"`

	// sum of the sources (denomenator)
	SumSrc tensor.Float32 `display:"no-inline"`

	// temporary destination sum for MPI -- only used when MPISum called
	MPITmp tensor.Float32 `display:"no-inline"`
}

RF is used for computing an activation-based receptive field. It simply computes the activation weighted average of other *source* patterns of activation -- i.e., sum(act * src) / sum(src) which then shows you the patterns of source activity for which a given unit was active. You must call Init to initialize everything, Reset to restart the accumulation of the data, and Avg to compute the resulting averages based an accumulated data. Avg does not erase the accumulated data so it can continue beyond that point.

func (*RF) Add

func (af *RF) Add(act, src tensor.Tensor, thr float32)

Add adds one sample based on activation and source tensor values. these must be of the same shape as used when Init was called. thr is a threshold value on sources below which values are not added (prevents numerical issues with very small numbers)

func (*RF) Avg

func (af *RF) Avg()

Avg computes RF as SumProd / SumSrc. Does not Reset sums.

func (*RF) AvgNorm

func (af *RF) AvgNorm()

AvgNorm computes RF as SumProd / SumTarg and then does Norm. This is what you typically want to call before viewing RFs. Does not Reset sums.

func (*RF) ConfigView

func (af *RF) ConfigView(tsr *tensor.Float32)

ConfigView configures the view params on the tensor

func (*RF) Init

func (af *RF) Init(name string, act, src tensor.Tensor)

Init initializes this RF based on name and shapes of given tensors representing the activations and source values.

func (*RF) InitShape

func (af *RF) InitShape(act, src tensor.Tensor) []int

InitShape initializes shape for this RF based on shapes of given tensors representing the activations and source values. does nothing if shape is already correct. return shape ints

func (*RF) MPISum

func (af *RF) MPISum(comm *mpi.Comm)

MPISum aggregates RF Sum data across all processors in given mpi communicator. It adds to SumProd and SumSrc. Call this prior to calling NormAvg().

func (*RF) Norm

func (af *RF) Norm()

Norm computes unit norm of RF values -- must be called after Avg

func (*RF) Reset

func (af *RF) Reset()

Reset reinitializes the Sum accumulators -- must have called Init first

type RFs

type RFs struct {

	// map of names to indexes of RFs
	NameMap map[string]int

	// the RFs
	RFs []*RF
}

RFs manages multiple named RF's -- each one must be initialized first but functions like Avg, Norm, and Reset can be called generically on all.

func (*RFs) Add

func (af *RFs) Add(name string, act, src tensor.Tensor, thr float32) error

Add adds a new act sample to the accumulated data for given named rf

func (*RFs) AddRF

func (af *RFs) AddRF(name string, act, src tensor.Tensor) *RF

AddRF adds a new RF, calling Init on it using given act, src tensors

func (*RFs) Avg

func (af *RFs) Avg()

Avg computes RF as SumProd / SumTarg. Does not Reset sums.

func (*RFs) AvgNorm

func (af *RFs) AvgNorm()

AvgNorm computes RF as SumProd / SumTarg and then does Norm. This is what you typically want to call before viewing RFs. Does not Reset sums.

func (*RFs) MPISum

func (af *RFs) MPISum(comm *mpi.Comm)

MPISum aggregates RF Sum data across all processors in given mpi communicator. It adds to SumProd and SumSrc. Call this prior to calling NormAvg().

func (*RFs) Norm

func (af *RFs) Norm()

Norm computes unit norm of RF values -- must be called after Avg

func (*RFs) RFByName

func (af *RFs) RFByName(name string) (*RF, error)

RFByName returns RF of given name, nil and error msg if not found.

func (*RFs) Reset

func (af *RFs) Reset()

Reset resets Sum accumulations for all rfs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL