-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest.py
More file actions
48 lines (46 loc) · 1.11 KB
/
test.py
File metadata and controls
48 lines (46 loc) · 1.11 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#-*- coding:utf-8 -*-
'''
Created on 2016��5��17��
@author: Administrator
'''
import util
from bean import autoencoder,nn
import numpy as np
x = np.array([[0,0,1,0,0],
[0,1,1,0,1],
[1,0,0,0,1],
[1,1,1,0,0],
[0,1,0,1,0],
[0,1,1,1,1],
[0,1,0,0,1],
[0,1,1,0,1],
[1,1,1,1,0],
[0,0,0,1,0]])
y = np.array([[0],
[1],
[0],
[1],
[0],
[1],
[0],
[1],
[1],
[0]])
#################################
# step1 建立autoencoder
#弄两层autoencoder
nodes=[5,3,2]
#建立auto框架
ae = util.aebuilder(nodes)
#设置部分参数
#训练
ae = util.aetrain(ae, x, 6000)
##############################
# step2 微调
#建立完全体的autoencoder
nodescomplete = np.array([5,3,2,1])
aecomplete = nn(nodescomplete)
for i in range(len(nodescomplete)-2):
aecomplete.W[i] = ae.encoders[i].W[0]
aecomplete = util.nntrain(aecomplete, x, y, 6000)
print aecomplete.values[3]