コード例 #1
0
ファイル: trainPyBrain.py プロジェクト: princengoc/gridcode
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 26 12:55:44 2014

@author: princengoc

Training using pybrain
"""
from gridcells import Gridcode, ncr

gc = Gridcode((9, 10, 11, 13), 0.5)
gc.computeBinaryDict()
input = gc.getInput()

# take some collection of cliques as targets
from cliqueFinder import randomClique

V = 16
targets = []
vertexList = set()
ctr = 0
while ctr < gc.r:
    clique, vx = randomClique(V)
    if vx not in vertexList:
        vertexList.add(vx)
        targets.append(clique.tolist())
        ctr = ctr + 1


# using pybrain
# test their xor example
コード例 #2
0
ファイル: trainPyLearn.py プロジェクト: princengoc/gridcode
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 26 12:56:51 2014

@author: princengoc

Train using pylearn2. We shall use the word representation. 
Also, we represent a clique by its set of vertices, rather than its
set of edges.
"""

from gridcells import Gridcode, ncr
from trainOneNode import softMaxFit
import numpy as np

gc = Gridcode((9, 10, 11, 13), 0.5)
gc.computeWordDict()

#take some collection of cliques as targets
from cliqueFinder import randomVertex
V = 14
targets = []
vertexList = []
ctr = 0
vxlist = None
while ctr < gc.r:
    vxlist, vxvec = randomVertex(V, frac = 0.5, vxlist = vxlist)
    if(vxvec not in targets):
        targets.append(vxvec)
        vertexList.append(vxlist)
        ctr = ctr + 1