view sandbox/simple_autoassociator/main.py @ 417:4f61201fa9a9

Parameters are no longer global
author Joseph Turian <turian@iro.umontreal.ca>
date Fri, 11 Jul 2008 17:19:37 -0400
parents 8849eba55520
children
line wrap: on
line source

#!/usr/bin/python
"""
    A simple autoassociator.

    The learned model is::
       h   = sigmoid(dot(x, w1) + b1)
       y   = sigmoid(dot(h, w2) + b2)

    Binary xent loss.
"""


import numpy

nonzero_instances = []
nonzero_instances.append({0: 1, 1: 1})
nonzero_instances.append({0: 1, 2: 1})

#nonzero_instances.append({1: 0.1, 5: 0.5, 9: 1})
#nonzero_instances.append({2: 0.3, 5: 0.5, 8: 0.8})
##nonzero_instances.append({1: 0.2, 2: 0.3, 5: 0.5})

import model
model = model.Model(input_dimension=10, hidden_dimension=4)

for i in xrange(100000):
#    # Select an instance
#    instance = nonzero_instances[i % len(nonzero_instances)]

    # Update over instance
    model.update(nonzero_instances)