-
Notifications
You must be signed in to change notification settings - Fork 2
/
cnn_parallel.py
executable file
·32 lines (26 loc) · 1.47 KB
/
cnn_parallel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
import Renascence
def getPieceProducer():
producer = Renascence.init(["./libAbstract_learning.xml"])
print producer
p_producer = Renascence.PieceFunctionProducer(producer, ['./parallel.xml'], ['Map-Reduce.xml'])
print p_producer
sub_p_producer = Renascence.PieceFunctionProducerParallel(p_producer, 'server')
return sub_p_producer
producer = getPieceProducer()
print producer
gd = producer.createInput(dataType='ALGradientMethod', path='./pieces/lenet/info/', keyDimesions=[1]);
#p = producer.createFunction('ParameterInit(x0)', 'ALGradientMethod').run([gd])
p = producer.createInput(path='output/pieces/parameters/', dataType='ALFloatMatrix', keyDimesions=[1])
train_x = producer.createInput(dataType='ALFloatMatrix',path='./pieces/lenet/trainX/', keyDimesions=[6])
train_y = producer.createInput(dataType='ALFloatMatrix',path='./pieces/lenet/trainY/', keyDimesions=[6])
merge = producer.createFunction('GDMatrixPrepare(x0,x1,x2)', 'ALFloatMatrix ALFloatMatrix ALGradientMethod').run([train_x, train_y, gd])
print merge
train_F = producer.createFunction('MatrixPlusM(MatrixPlus(GDCompute(x0,x1,x2)), x2)', 'ALFloatMatrix ALGradientMethod ALFloatMatrix')
for i in range(0, 50):
print i
p = train_F.run([merge, gd, p])
#tempP = producer.createFunction('GDCompute(x0,x1,x2)', 'ALFloatMatrix ALGradientMethod ALFloatMatrix').run([merge, gd, p])
print p
outputDetP = producer.createOutput('output/pieces/parameters')
producer.copyPiece(p, outputDetP)