sequenceLength = 70
(sensorySequence, motorSequence, sensorimotorSequence) =  \
  smseq.generateSensorimotorSequence(sequenceLength)

sensoryInputWidth = smseq.lengthSensoryInput
motorCommandWidth = smseq.lengthMotorInput1D

# Create Temporal Memory instance with appropriate parameters
tm = TM_SM(numberOfCols=sensoryInputWidth,
           numberOfDistalInput=motorCommandWidth + sensoryInputWidth,
           cellsPerColumn=8,
           initialPerm=0.5,
           connectedPerm=0.6,
           minThreshold=10,
           newSynapseCount=50,
           newDistalSynapseCount=21,
           permanenceInc=0.1,
           permanenceDec=0.02,
           activationThreshold=10,
           globalDecay=0,
           burnIn=1,
           learnOnOneCell=True,
           verbosity=0)

# Step 3: send this simple sequence to the temporal memory for learning
print " Training Layer 4 temporal memory ..."

# Send each letter in the sequence in order
for j in range(sequenceLength):

    print "\nPosition:", j, "========================="
sensoryInputWidth = smseqs[0].lengthSensoryInput
motorCommandWidth = smseqs[0].lengthMotorInput1D

print "motorCommandWidth",motorCommandWidth

# Create Temporal memory instance with appropriate parameters
# It performs sensorimotor inference, simulating layer 4
tm = TM_SM(numberOfCols=sensoryInputWidth,
        numberOfDistalInput=motorCommandWidth+sensoryInputWidth,
        cellsPerColumn=8,
        initialPerm=0.4,
        connectedPerm=0.5,
        minThreshold=45,
        activationThreshold=45,
        newSynapseCount=50,
        newDistalSynapseCount=50,
        permanenceInc=0.1,
        permanenceDec=0.02,
        learnOnOneCell=True,
        learnDistalInputs=True,
        learnLateralConnections=False,
        globalDecay=0,
        burnIn=1,
        verbosity = 0)

print "\nLayer 4 TM parameters:"
tm.printParameters()


#######################################################################
#
sensoryInputWidth = smseqs[0].lengthSensoryInput
motorCommandWidth = smseqs[0].lengthMotorInput1D

print "motorCommandWidth",motorCommandWidth

# Create Temporal memory instance with appropriate parameters
# It performs sensorimotor inference, simulating layer 4
tm = TM_SM(numberOfCols=sensoryInputWidth,
        numberOfDistalInput=motorCommandWidth+sensoryInputWidth,
        cellsPerColumn=8,
        initialPerm=0.4,
        connectedPerm=0.5,
        minThreshold=45,
        activationThreshold=45,
        newSynapseCount=50,
        newDistalSynapseCount=50,
        permanenceInc=0.1,
        permanenceDec=0.02,
        learnOnOneCell=True,
        learnDistalInputs=True,
        learnLateralConnections=False,
        globalDecay=0,
        burnIn=1,
        verbosity = 0)

print "\nLayer 4 TM parameters:"
tm.printParameters()


#######################################################################
#
sequenceLength = 70
(sensorySequence, motorSequence, sensorimotorSequence) =  \
  smseq.generateSensorimotorSequence(sequenceLength)

sensoryInputWidth = smseq.lengthSensoryInput
motorCommandWidth = smseq.lengthMotorInput1D

# Create Temporal Memory instance with appropriate parameters
tm = TM_SM(numberOfCols=sensoryInputWidth,
           numberOfDistalInput=motorCommandWidth + sensoryInputWidth,
           cellsPerColumn=8,
           initialPerm=0.5,
           connectedPerm=0.6,
           minThreshold=10,
           newSynapseCount=50,
           newDistalSynapseCount=21,
           permanenceInc=0.1,
           permanenceDec=0.02,
           activationThreshold=10,
           globalDecay=0,
           burnIn=1,
           learnOnOneCell=True,
           verbosity=0)


# Step 3: send this simple sequence to the temporal memory for learning
print " Training Layer 4 temporal memory ..."

# Send each letter in the sequence in order
for j in range(sequenceLength):