# deterministic Boltzmann machine (trained with contrastive Hebbian learning)

addNet HS-dbm -i 11 -t 4 BOLTZMAN
# first four intervals are positive phase (inputs and output clamped)
# last six intervals are negative phase (just inputs clamped)

addGroup output  68 OUTPUT -BIASED
addGroup ident   40 OUTPUT SOFT_MAX
connectGroups output ident
loadWeights HS-dbm-ident.wt
freezeWeights
setObj ident.errorScale 0.0

addGroup input   28 INPUT
addGroup hidden  50
connectGroups input hidden output hidden
connectGroups bias output -mean -1.0 -range 0.0

# seed random number generator
seed 12345
# randomize weights
resetNet
symmetrizeWeights
loadWeights HS-dbm.init.wt

setObj hidden.initOutput  0.2
setObj output.initOutput  0.2

loadExamples HS-dbm_ex.txt -s train-dbm
# let positive phase end after 5 intervals
setObj train-dbm.minTime   4.0
setObj train-dbm.maxTime   7.0

setObj clampStrength   1.0
setObj initGain        0.1
setObj finalGain       1.0
setObj annealTime      0.7

setObj unitCellSize 40
resetPlot
plotRow * n ident 20
plotRow 1 f
plotRow * n output 17 
plotRow 1 f
plotRow * n hidden 20
plotRow 1 f
plotRow  n input 11
plotRow  n input 5
plotRow  n input 10
plotRow  n input 2
drawUnits

setObj input.unit(0).name  b/1
setObj input.unit(1).name  c/1	
setObj input.unit(2).name  d/1	
setObj input.unit(3).name  g/1	
setObj input.unit(4).name  h/1	
setObj input.unit(5).name  l/1	
setObj input.unit(6).name  m/1	
setObj input.unit(7).name  n/1	
setObj input.unit(8).name  p/1	
setObj input.unit(9).name  r/1	
setObj input.unit(10).name t/1	
setObj input.unit(11).name a/2	
setObj input.unit(12).name e/2	
setObj input.unit(13).name i/2	
setObj input.unit(14).name o/2	
setObj input.unit(15).name u/2	
setObj input.unit(16).name b/3	
setObj input.unit(17).name c/3	
setObj input.unit(18).name d/3	
setObj input.unit(19).name g/3	
setObj input.unit(20).name n/3	
setObj input.unit(21).name m/3	
setObj input.unit(22).name p/3	
setObj input.unit(23).name r/3	
setObj input.unit(24).name t/3	
setObj input.unit(25).name w/3	
setObj input.unit(26).name e/4	
setObj input.unit(27).name k/4	

setObj ident.unit(0).name  BED
setObj ident.unit(1).name  CAN 
setObj ident.unit(2).name  COT 
setObj ident.unit(3).name  CUP 
setObj ident.unit(4).name  GEM 
setObj ident.unit(5).name  MAT 
setObj ident.unit(6).name  MUG 
setObj ident.unit(7).name  PAN 
setObj ident.unit(8).name  BUG 
setObj ident.unit(9).name  CAT 
setObj ident.unit(10).name COW 
setObj ident.unit(11).name DOG 
setObj ident.unit(12).name HAWK
setObj ident.unit(13).name PIG 
setObj ident.unit(14).name RAM 
setObj ident.unit(15).name RAT 
setObj ident.unit(16).name BACK
setObj ident.unit(17).name BONE
setObj ident.unit(18).name GUT 
setObj ident.unit(19).name HIP 
setObj ident.unit(20).name LEG 
setObj ident.unit(21).name LIP 
setObj ident.unit(22).name PORE
setObj ident.unit(23).name RIB 
setObj ident.unit(24).name BUN 
setObj ident.unit(25).name HAM 
setObj ident.unit(26).name HOCK
setObj ident.unit(27).name LIME
setObj ident.unit(28).name NUT 
setObj ident.unit(29).name POP 
setObj ident.unit(30).name PORK
setObj ident.unit(31).name RUM 
setObj ident.unit(32).name BOG 
setObj ident.unit(33).name DEW 
setObj ident.unit(34).name DUNE
setObj ident.unit(35).name LOG 
setObj ident.unit(36).name MUD 
setObj ident.unit(37).name PARK
setObj ident.unit(38).name ROCK
setObj ident.unit(39).name TOR 

setObj learningRate 0.03
setObj numUpdates 600
echo "numLinks =" [getObj numLinks]
# 11078
graphObject error
