Exemplo n.º 1
0
def test():
	import sys
	sys.path.insert(0,'digit_reconstructor\\rbm')
	sys.path.insert(0,'digit_reconstructor\\dbn')

	print("Loading DBN\n")
	import cPickle as cP
	with open("data\\defValues-300-300.pklb","rb") as f:
		a=cP.load(f)
	import dbn
	import rbm0_m as rbm0
	r=rbm0.rbm0()
	r.weights=a[0]
	r.load_data()

	d=dbn.dbn([r],30)
	d.rbmList[1].weights=a[1]

	print("Loaded DBN\n")

	epochs = 20

	print("Training DBN\n")
	d.train(epochs)

	dweights =[]

	print("Saving DBN weights\n")
	for x in xrange(len(d.rbmList)):
		dweights.append(d.rbmList[x].weights)

	file_write_name="new_weights-784-300-30.pklb"
	with open(file_write_name,"wb") as f:
		cP.dump(dweights,f)

	print("Displaying DBN reconstructed digits")
	import dbninter
	dbninter.display(d)
Exemplo n.º 2
0
    def __init__(self, rbmList, no_final_h, mrat=.5, eta=.001, p=.01):
        sizes = [rbmList[0].size[0]]
        sizes.extend([rbmList[k].size[1] for k in xrange(len(rbmList))])
        sizes.extend([no_final_h])
        self.rbmList = [rbmList[k] for k in xrange(len(rbmList))]

        self.rbmList.append(rbm0.rbm0((sizes[-2], sizes[-1])))
        self.rbmList[-1].data = rbmList[0].data

        self.sizes = sizes
        #initialize weights
        #initalize network

        self.data = rbmList[0].data
        self.num_layers = len(rbmList)

        self.default_weight_initializer()
        self.reconError = 0  #sum of squared error terms, averaged over a mini_batch
        #np.empty((785,0))#this is the distance between the trainV and the reconV, summed over a mini_batch
        self.p = p  # the desired sparsity of the hidden activations
        self.q = 0
        self.mrat = mrat
        self.eta = eta
Exemplo n.º 3
0
#Interpreter python2
#displays the dbn reconstructed digits

import sys
sys.path.insert(0,'..\\rbm')


print("Loading DBN\n")
import cPickle as cP
with open("..\\..\\data\\defValues-300-300.pklb","rb") as f:
	a=cP.load(f)
import dbn
import rbm0_m as rbm0
r=rbm0.rbm0()
r.weights=a[0]
r.load_data()
d=dbn.dbn([r],30)
d.rbmList[1].weights=a[1]

print("Displaying DBN\n")
import dbninter
dbninter.display(d)
Exemplo n.º 4
0
def defdisplay():
    r = rbm0.rbm0()
    r.load_binary_images()
    import cPickle as cP
    r.weights = cP.load(open("rbmWeights_300h.pklb", "rb"))
    display(r)