Introduction to Neural Networks
U. Minn. Psy 5038

Supplement on:
Contingent Adaptation and Neural Networks

Initialization

Off[SetDelayed::write]
Off[General::spell1]

Contingent Adaptation: McCollough effect

Celeste McCollough (1965).

Make stimulus

width = 128; freq=8;
grating[x_,y_,xfreq_,yfreq_] := Sign[Cos[(2. Pi)*(xfreq*x + yfreq*y)]];

Vertical red adapting grating

xfreq=freq;theta=Pi/2;
yfreq=xfreq/Tan[theta];

gvertred=DensityPlot[grating[x,y,xfreq,yfreq],{x,0,1},{y,0,1},PlotPoints->width,Mesh->False,Frame->False,ColorFunction->(RGBColor[#,0,0]&), DisplayFunction->Identity];

Horizontal green adapting grating

xfreq=0;theta=0;
yfreq=freq;

ghorizgreen=DensityPlot[grating[x,y,xfreq,yfreq],{x,0,1},{y,0,1},PlotPoints->width,Mesh->False,Frame->False,ColorFunction->(RGBColor[0,#,0]&), DisplayFunction->Identity];

Horizontal gray test grating

xfreq=0;
yfreq=freq;

ghorizgray=DensityPlot[grating[x,y,xfreq,yfreq],{x,0,1},{y,0,1},PlotPoints->width,Mesh->False,Frame->False,ColorFunction->(RGBColor[#,#,#]&), DisplayFunction->Identity];

Vertical gray test grating

xfreq=freq;
yfreq=0;

gvertgray=DensityPlot[grating[x,y,xfreq,yfreq],{x,0,1},{y,0,1},PlotPoints->width,Mesh->False,Frame->False,ColorFunction->(RGBColor[#,#,#]&), DisplayFunction->Identity];

Test: Try it

1. First look at the two black and white gratings below on the right. They should look black and white, and the white should have little or no tinges of color.
2. Now look at the left vertical red grating, then the right horizontal green, then back at the left and so forth for 2-4 minutes. (You can use Pause[] for timing in seconds). 
3. Then when adapted, look at the black and white test gratings again. The white bars of horizontal B&W should look pinkish, and the vertical bars greenish.

Show[GraphicsGrid[{{gvertred,ghorizgreen,ghorizgray,gvertgray}},Spacings->{Scaled[0.01`],Scaled[0.01`]}]]

Pause[120]
"done"

Is there a functional explanation for what is going on? Is there a neural network explanation?

Barlow suggested that adaptation is the result of the visual system adjusting to new statistical dependencies between features. It isn't just that neurons are "getting tired". Specifically, he suggested that perceptual systems adjust their representations of features to be independent or uncorrelated with each other (technically, independence is a stronger condition). This is a problem of neural self-organization, perceptual learning based on experience. Next we'll look at several neural networks that re-organize to decrease the correlations between their firing. One network may provide an explanation for McCulloch's color-contingent affter-effect.

Non-orthogonal decorrelation & contingent adaptation

Foldiak's  scheme combining Hebbian and anti-Hebbian learning

Rigid rotations aren't the only possible transformations that decorrelate the inputs. Further, one might want a new coordinate system that shares the variance equally--after all, we do not have strong evidence that neurons vary greatly in their ability to code the range of variation. This section looks at a network due to Peter Foldiak.

Foldiak and Barlow devised a neural network that combined a Hebbian learning rule on the forward connections with anti-Hebbian learning on the inhibitory connections between the output units.  Oja's rule was used to normalize the weights. It can be shown that decorrelated output values are steady-state solutions for the weight changes. 
One of the reasons for interest in this kind of model are the potential relations with the physiology. Inhibitory links are well-known, and evidence for anti-Hebbian learning is something to be looked for empirically.

Linear neural transform, weight matrix A

Setup coordinate frame graphics

lineg=Plot[{},{x,-1,1}, PlotRange->{{0,1.1},{0,1.1}}, AspectRatio->1,Frame->True, FrameLabel->{"x","y"},DisplayFunction->Identity];

Define the neural net transform as a function called: transform[]:

A = 2.5*{{1,-7/11},{-1/2,1}};
transform[x_]:=A.x;
invtransform[x_]:=Inverse[A].x;

Pre-adaptation feature space (x-y): (xp,yp)=Identity.(x,y)

Define adaptation points, and coordinate lines in x-y space

Generate adaptation points

t1=Flatten[Table[{x,y},{x,0.1`,1,0.1`},{y,0.1`,1,0.1`}],1];
color=Table[Min[1,invtransform[t1[[i]]][[2]]],{i,1,Length[t1]}];
adaptp=invtransform/@t1;
preadapaptg=Graphics[({RGBColor[color[[#1]],1-color[[#1]],0],Disk[adaptp[[#1]],0.02`]}&)/@Range[1,Length[adaptp]],AspectRatio->Automatic];

Generate  GRAY y=0.5 coordinate lines in x-y space: Separates RED from GREEN

grayyl=Table[{x,0.5`},{x,0,1,0.01`}];grayylg=Graphics[{PointSize[0.01`],RGBColor[0.8`,0.8`,0.8`],Point/@grayyl}];

Generate  BLUE x-y coordinate lines in x-y space

xl=Table[{x,0},{x,0,1,.01}];
yl=Table[{0,y},{y,0,1,.01}];

xlg=Graphics[{PointSize[0.02`],RGBColor[0,0,1],Point/@xl}];ylg=Graphics[{PointSize[0.02`],RGBColor[0,0,1],Point/@yl}];

Show plot of correlated data in (BLUE) x-y space

Show[lineg,xlg,ylg,preadapaptg,grayylg,Graphics[{Text["Red Zone",{0.2`,0.8`}],Text["Green Zone",{0.8`,0.2`}],Text["Horizontal",{0.2`,-0.1`}],Text["Vertical",{0.8`,-0.1`}]}],PlotRange->{{-0.5`,1.1`},{-0.5`,1.1`}},Background->GrayLevel[0.4]]

Plot of pre-adaptation feature space with desired  transformed coordinates (YELLOW) in x-y space

Generate YELLOW xp-yp coordinate lines in x-y space

xpl=Map[invtransform,Table[{x,0},{x,0,1.4,.01}]];
ypl=Map[invtransform,Table[{0,y},{y,0,1.4,.01}]];

xplg=Graphics[{PointSize[0.02`],RGBColor[1,1,0],Point/@xpl}];yplg=Graphics[{PointSize[0.02`],RGBColor[1,1,0],Point/@ypl}];

Show[lineg,xplg,yplg,xlg,ylg,preadapaptg,grayylg,PlotRange->{{-0.5`,1.1`},{-0.5`,1.1`}},Background->GrayLevel[0.4]]

Post-adaptation remapped feature space (xp,yp): (xp,yp) = A.(x,y)

Generate  new DARK GRAY y=0.5 coordinate lines in x-y space

newgrayyl=Table[{x,0.5`},{x,0,1,0.01`}];newgrayylg=Graphics[{PointSize[0.01`],RGBColor[0.4`,0.4`,0.4`],Point/@newgrayyl}]

Generate  old LIGHT GRAY y=0.5 coordinate lines in x-y space

oldgrayyl=Table[{x,0.5`},{x,0,1,0.01`}];oldgrayyl=transform/@oldgrayyl;oldgrayylg=Graphics[{PointSize[0.01`],RGBColor[0.8`,0.8`,0.8`],Point/@oldgrayyl}]

Remap RED/GREEN adaptation points

(t1=Flatten[Table[{x,y},{x,0.1`,1,0.1`},{y,0.1`,1,0.1`}],1];) (color=Table[Min[1,invtransform[t1[[i]]][[2]]],{i,1,Length[t1]}];) (adaptp=t1;) (postadapaptg=Graphics[({RGBColor[color[[#1]],1-color[[#1]],0],Disk[adaptp[[#1]],0.03`]}&)/@Range[1,Length[adaptp]],AspectRatio->Automatic])

Remap  x-y coordinate lines (BLUE) in xp-yp  space

remapxl=Map[transform,xl];
remapyl=Map[transform,yl];

remapxlg=Graphics[{PointSize[0.02`],RGBColor[0,0,1],Point/@remapxl}];remapylg=Graphics[{PointSize[0.02`],RGBColor[0,0,1],Point/@remapyl}]

Remap  xp-yp coordinate lines (YELLOW) in xp-yp  space

remapxpl=Map[transform,xpl];
remapypl=Map[transform,ypl];

remapxplg=Graphics[{PointSize[0.01`],RGBColor[1,1,0],Point/@remapxpl}];remapyplg=Graphics[{PointSize[0.01`],RGBColor[1,1,0],Point/@remapypl}]

Show[lineg,postadapaptg,remapxlg,remapxplg,remapylg,remapyplg,remaplineg,newgrayylg,oldgrayylg,Graphics[{Text["New Red Zone",{0.5`,0.6`}],Text["New Green Zone",{0.5`,0.4`}],Text["Old B&W boundary",{-0.1`,0.9`}]}],DisplayFunction->$DisplayFunction,PlotRange->{{-0.5`,1.1`},{-0.5`,1.1`}},Background->GrayLevel[0.3`]]

Bibliography

Barlow, H. B., & Foldiak, P. (1989). Adaptation and decorrelation in the cortex. In C. Miall, R. M. Durban, & G. J. Mitchison (Ed.), The Computing Neuron Addison-Wesley.
Barlow, H. (1990). Conditions for versatile learning, Helmholtz's unconscious inference, and the task of perception. Vision Research, 30(11), 1561-1572.
McCollough, C. (1965, 3 September 1965). Color Adaptation of Edge-Detectors in the Human Visual System. Science, 149, 1115-1116.