<commit_before>""" This module implements the idea of finding out emotions similarities
by using the experiments similar to what Hinton describes in his NRelu paper."""


import argparse
import restrictedBoltzmannMachine as rbm

import numpy as np
import theano
from theano import tensor as T
from sklearn import cross_validation

from common import *
from readfacedatabases import *

theanoFloat  = theano.config.floatX


parser = argparse.ArgumentParser(description='digit recognition')
parser.add_argument('--relu', dest='relu',action='store_true', default=False,
                    help=("if true, trains the RBM or DBN with a rectified linear unit"))

args = parser.parse_args()

class Trainer(object):

  def __init__(self, input1, input2, net):

    self.w = theano.shared(value=np.float32(0))
    self.b = theano.shared(value=np.float32(0))
    self.net = net

    theanoRng = RandomStreams(seed=np.random.randint(1, 1000))


    # Do I need to add all biases? Probably only the hidden ones
    # self.params = [self.w, self.b, self.net.sharedWeights] + self.net.sharedBiases
    self.params = [self.w, self.b]

    self.reconstructer1 = self.net.buildReconstructerForSymbolicVariable(input1, theanoRng)
    self.reconstructer2 = self.net.buildReconstructerForSymbolicVariable(input2, theanoRng)

    # This also has to be some theano graph
    hiddens1 = self.reconstructer1.hiddenActivations
    hiddens2 = self.reconstructer2.hiddenActivations

    cos = cosineDistance(hiddens1, hiddens2)

    self.updates = self.reconstructer1.updates + self.reconstructer2.updates
    prob = 1.0 /( 1.0 + T.exp(self.w * cos + self.b))

    self.output = prob


class SimilarityNet(object):

  # TODO: add sizes and activation functions here as well
  # plus rbm learning rates
  def __init__(learningRate):
    self.learningRate = learningRate

  def _trainRBM(self, data1, data2):
    data = np.vstack([data1, data2])
    activationFunction = T.nnet.sigmoid

    net = rbm.RBM(1200, 500, 0.001, 1, 1,
                    binary=1-args.relu,<commit_msg>forgot to add self to constructor<commit_after>""" This module implements the idea of finding out emotions similarities
by using the experiments similar to what Hinton describes in his NRelu paper."""


import argparse
import restrictedBoltzmannMachine as rbm

import numpy as np
import theano
from theano import tensor as T
from sklearn import cross_validation

from common import *
from readfacedatabases import *

theanoFloat  = theano.config.floatX


parser = argparse.ArgumentParser(description='digit recognition')
parser.add_argument('--relu', dest='relu',action='store_true', default=False,
                    help=("if true, trains the RBM or DBN with a rectified linear unit"))

args = parser.parse_args()

class Trainer(object):

  def __init__(self, input1, input2, net):

    self.w = theano.shared(value=np.float32(0))
    self.b = theano.shared(value=np.float32(0))
    self.net = net

    theanoRng = RandomStreams(seed=np.random.randint(1, 1000))


    # Do I need to add all biases? Probably only the hidden ones
    # self.params = [self.w, self.b, self.net.sharedWeights] + self.net.sharedBiases
    self.params = [self.w, self.b]

    self.reconstructer1 = self.net.buildReconstructerForSymbolicVariable(input1, theanoRng)
    self.reconstructer2 = self.net.buildReconstructerForSymbolicVariable(input2, theanoRng)

    # This also has to be some theano graph
    hiddens1 = self.reconstructer1.hiddenActivations
    hiddens2 = self.reconstructer2.hiddenActivations

    cos = cosineDistance(hiddens1, hiddens2)

    self.updates = self.reconstructer1.updates + self.reconstructer2.updates
    prob = 1.0 /( 1.0 + T.exp(self.w * cos + self.b))

    self.output = prob


class SimilarityNet(object):

  # TODO: add sizes and activation functions here as well
  # plus rbm learning rates
  def __init__(self, learningRate):
    self.learningRate = learningRate

  def _trainRBM(self, data1, data2):
    data = np.vstack([data1, data2])
    activationFunction = T.nnet.sigmoid

    net = rbm.RBM(1200, 500, 0.001, 1, 1,
                    binary=1-args.relu,
{'fraction_non_alphanumeric': 0.09612590799031477, 'fraction_numerical': 0.022760290556900726, 'mean_word_length': 3.854289071680376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7513064', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1302, 'n_words': 359}