Skip to content

Instantly share code, notes, and snippets.

"""Implementation of restricted Boltzmann machine."""
import numpy as np
from common import *
from activationfunctions import *
import theano
from theano import tensor as T
from theano.tensor.shared_randomstreams import RandomStreams
trainFunction = theano.function(
inputs=[miniBatchIndex, momentum, cdSteps],
outputs=[], # TODO: output error
updates=updates,
givens={
x: sharedData[miniBatchIndex * self.miniBatchSize:(miniBatchIndex + 1) * self.miniBatchSize],
})
def rbmEmotions(big=False, reconstructRandom=False):
#data, labels = readMultiPIE(big, equalize=args.equalize)
data, labels = readother.read()
print "data.shape"
print data.shape
data = data / 255.0
labels = labels / 255.0
if args.relu:
activationFunction = Rectified()
data = scale(data)
Traceback (most recent call last):
File "emotions.py", line 1613, in <module>
main()
File "emotions.py", line 1576, in main
rbmEmotions()
File "emotions.py", line 137, in rbmEmotions
net.train(trainData)
File "/home/vlad/individProject/restrictedBoltzmannMachine.py", line 316, in train
trainFunction(miniBatchIndex, momentum, step)
File "/home/vlad/individProject/DBenv/local/lib/python2.7/site-packages/theano/compile/function_module.py", line 588, in __call__
python emotions.py --train --rbm --maxEpochs 1 tr
data.shape
(726, 625)
labels.shape (726, 625)
trainData (725, 1250)
hidden dropout in RBM 1
visible dropout in RBM 1
rbm learningRate
1.2
data set size for restricted boltzmann machine
import os.path
from PIL import Image
import numpy as np
nrDataPoints = 174
imageSize = 25
emotionArray = ["google", "pi", "twitter"]
associations = {"google": "pi", "twitter": "google", "pi":"twitter"}
labelBits = imageSize**2
classLabels = {}
@valadhi
valadhi / gsoc19_multiclassification.gist
Last active November 28, 2019 04:12
GSOC 2019: Adding multiclassification to Machine Learning backends
This project involves adding multi-classification capabilities to the Moodle Machine Learning backends.
The current prediction processor API is limited to supervised learning binary classifiers.
Some models will require multiple classes to be able to predict if a student will receive a grade which will be 'very low',
'low', 'normal', 'high' or 'very high'.
This involved two parts:
[ ] Adjusting the PHP Moodle core code to work with multi-class cases. Also, adding unit tests for all the changes.
Squashed commit with all the changes introduced can be found at:
https://github.com/valadhi/moodle/commit/093b99efb7e689691ebd1c1d85ee9d3d1552d822
[ ] Setting up the python Tensorflow backend to accept training, prediction and evaluation of multi-class datasets.