Skip to content

Commit

Permalink
faces projection plots
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Aug 24, 2024
1 parent 3be03b7 commit 028cc7a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
8 changes: 7 additions & 1 deletion ch3/faces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ Also, you might be surprised to know that most of the neural networks currently

# Weights as a Projection operation

TODO:
![How synaptic weights act to *project* input patterns along specific *dimensions* or bases, in this case projecting the inputs along the dimensions of Emotion and Gender. In the left panel, the very high-dimensional face inputs (256 dimensions for a 16x16 image) are projected along two random weight vectors, allowing us to visualize this high-dimensional input space in a 2D plot. In the right panel, the specific synaptic weights trained for discriminating along the emotion vs. gender dimensions have *transformed* or *rotated* the input space into a much more systematic and well-organized, low-dimensional space. This is fundamentally what neurons do: organize and transform input patterns along relevant dimensions, and that is another way of stating that neurons detect stimuli along these dimensions. ](fig_face_categ_dim_prjn.png){#fig:fig-face-categ-dim-prjn width=100% }

[@fig:fig-face-categ-dim-prjn], which is Figure 3.8 in the textbook, illustrates how synaptic weights function to *project input patterns along a specific **dimension** in a high-dimensional space*. This process is illustrated in the `ProjectionRandom` and `ProjectionEmoteGend` plots that were generated with the `Cluster Plot` action. The `ProjectionRandom` plot shows what happens when the face inputs are projected along random dimensions, using random weights. Specifically, each axis plots the *dot product* of the input face times the random weight values generated for each axis. If you press `Cluster Plot` again, you can see a different random projection.

In general, you can see that the points for each person tend to land nearby to each other, which makes sense because the faces for the different emotions are overall relatively similar. Further, you can also see a general grouping of the same emotion. However, it is not systematically organized along the different dimensions. By contrast, when you look at `ProjectionEmoteGend` plot, you can see that the X axis, which projects the input faces along the gender dimensions systematically sorts male vs female faces. Likewise, the Y axis systematically separates sad vs. happy emotions.

As noted in the textbook the neural weights *rotate* the input space along a new *basis set* which provides a different way of *encoding* the inputs that emphasizes certain relevant dimensions while collapsing across other less relevant dimensions.


4 changes: 2 additions & 2 deletions ch3/faces/faces.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ func (ss *Sim) ProjectionPlot() {
// order of params: on, fixMin, min, fixMax, max
plt.SetColumnOptions("TrialName", plotcore.On, plotcore.FloatMin, 0, plotcore.FloatMax, 0)
plt.SetColumnOptions("GendPrjn", plotcore.Off, plotcore.FixMin, -1, plotcore.FixMax, 1)
plt.SetColumnOptions("RndPrjn0", plotcore.Off, plotcore.FixMin, -1, plotcore.FixMax, 1)
plt.SetColumnOptions("RndPrjn1", plotcore.On, plotcore.FixMin, -1, plotcore.FixMax, 1)
plt.SetColumnOptions("RndPrjn0", plotcore.Off, plotcore.FloatMin, -1, plotcore.FloatMax, 1)
plt.SetColumnOptions("RndPrjn1", plotcore.On, plotcore.FloatMin, -1, plotcore.FloatMax, 1)

plt = ss.GUI.PlotByName("ProjectionEmoteGend")
plt.Options.Title = "Face Emotion / Gender Projection Plot"
Expand Down
Binary file added ch3/faces/fig_face_categ_dim_prjn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/CompCogNeuro/sims/v2
go 1.22

require (
cogentcore.org/core v0.3.3-0.20240823053213-f975eb9c487c
github.com/emer/emergent/v2 v2.0.0-dev0.1.0.0.20240823054321-fa1ced2f310e
github.com/emer/leabra/v2 v2.0.0-20240823054502-746f3c3300a0
cogentcore.org/core v0.3.3-0.20240824041409-a3b72b4e5b61
github.com/emer/emergent/v2 v2.0.0-dev0.1.0.0.20240824052855-a2f0334c5e2f
github.com/emer/leabra/v2 v2.0.0-20240824053339-7649a39b7c0a
)

require (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cogentcore.org/core v0.3.3-0.20240823053213-f975eb9c487c h1:fPTsOnzaFa9WVzplGW7JtTAnQ845uc5c3t/kcklASHQ=
cogentcore.org/core v0.3.3-0.20240823053213-f975eb9c487c/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4=
cogentcore.org/core v0.3.3-0.20240824041409-a3b72b4e5b61 h1:1G8tQzATA1o9QRVbCV5+YTrQFkLSTZas2EiJS4bjiG8=
cogentcore.org/core v0.3.3-0.20240824041409-a3b72b4e5b61/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down Expand Up @@ -34,10 +34,10 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/emer/emergent/v2 v2.0.0-dev0.1.0.0.20240823054321-fa1ced2f310e h1:Gq3gh91l0/Vryi9XvHj+YcI/aiRXHb99VD2TwKLJwJw=
github.com/emer/emergent/v2 v2.0.0-dev0.1.0.0.20240823054321-fa1ced2f310e/go.mod h1:2yo06CIEywfYDU5T+gFc151JSAnxq/JEfWxLzOoA/sE=
github.com/emer/leabra/v2 v2.0.0-20240823054502-746f3c3300a0 h1:T9O7FE2pbQlHUW3+LB2mgEVSMrKcVWTasslGEluXDVs=
github.com/emer/leabra/v2 v2.0.0-20240823054502-746f3c3300a0/go.mod h1:/dg3kLjwtplWu46l7JNLcceyaQObu4+AMddWiQIA1Es=
github.com/emer/emergent/v2 v2.0.0-dev0.1.0.0.20240824052855-a2f0334c5e2f h1:MVMGnEy8BSzx11kv9n9a2cCYD5m1E9XP/fxVMEiXOx0=
github.com/emer/emergent/v2 v2.0.0-dev0.1.0.0.20240824052855-a2f0334c5e2f/go.mod h1:07PEZIlCPNkktQeyItej/UMqi/2fmlNPX7Wa2QGaCRk=
github.com/emer/leabra/v2 v2.0.0-20240824053339-7649a39b7c0a h1:NYTYSllgcFkemkSZCPYl2b7ovYaXCbbahS2pPQXDtFM=
github.com/emer/leabra/v2 v2.0.0-20240824053339-7649a39b7c0a/go.mod h1:K+w37eWwbyCY4Tr7walIfz6C1Bystx7/pF2KQ8dck1U=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
Expand Down

0 comments on commit 028cc7a

Please sign in to comment.