Skip to content

Commit e9abcd3

Browse files
committed
readme
1 parent 22726ea commit e9abcd3

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# dec
1+
# Deep Embedded Clustering
2+
3+
This package implements the algorithm described in paper "Unsupervised Deep Embedding for Clustering Analysis". It depends on opencv, numpy, scipy and Caffe.
4+
5+
This implementation is intended for reproducing the results in the paper. If you only want to try the algorithm and find caffe too difficault to install, there is an experimental implementation in MXNet: https://github.com/dmlc/mxnet/blob/master/example/dec/dec.py. MXNet is a flexible deep learning library with fewer dependencies. You are welcome to try it. Installation guide can be found here: https://mxnet.readthedocs.org/en/latest/build.html. Once you install MXNet, simple go into directory examples/dec and run ```python dec.py'''.
6+
7+
## Usage
8+
To run, please first build our custom version of Caffe included in this package following the official guide: http://caffe.berkeleyvision.org/installation.html.
9+
10+
Then download the data set you want to experiment on. We provide scripts for downloading the datasets used in the paper. For example you can download MNIST by ```cd mnist; ./get_data.sh'''. Once download completes, run ```cd dec; python make_mnist_data.py''' to prepare data for Caffe.
11+
12+
After data is ready, run ```python dec.py DB''' to run experiment on with DB. DB can be one of mnist, stl, reutersidf10k, reutersidf. We provide pretrained autoencoder weights with this package. You can use dec/pretrain.py to train your own autoencoder. Please read source for usage info.

dec/dec.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ def make_net(fnet, layers):
327327

328328
fnet.write('name: "net"\n')
329329
for k,v in layers:
330-
print k,v
331330
fnet.write(layer_dict[k].format(*v))
332331
fnet.close()
333332

@@ -748,14 +747,16 @@ def DisKmeans(db, update_interval = None):
748747

749748
if __name__ == '__main__':
750749
db = sys.argv[1]
750+
lam = 160
751751
"""acc_list = []
752752
nmi_list = []
753753
for i in xrange(0,9):
754-
acc, nmi = DisKmeans(db, 10*(2**i))
754+
lam = 10*(2**i)
755+
acc, nmi = DisKmeans(db, lam)
755756
acc_list.append(acc)
756757
nmi_list.append(nmi)
757758
print acc_list
758759
print nmi_list"""
759-
DisKmeans(db, 20)
760+
DisKmeans(db, lam)
760761

761762

dec/pretrain.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def main(db, params):
7272
snapshot_prefix: "exp/{4}/save"
7373
snapshot_after_train:true
7474
solver_mode: GPU
75-
debug_info: true
75+
debug_info: false
7676
device_id: 0""".format(rate, params['step'][0], niter, params['decay'][0],db ))
7777

7878

@@ -138,7 +138,7 @@ def pretrain_main(db, params):
138138
snapshot_prefix: "exp/{4}/save"
139139
snapshot_after_train:true
140140
solver_mode: GPU
141-
debug_info: true
141+
debug_info: false
142142
device_id: 0""".format(rate, params['step'][0], params['pt_iter'][0], params['decay'][0], db))
143143

144144
if i > 0:
@@ -160,7 +160,6 @@ def pretrain_main(db, params):
160160
del net
161161

162162
net = caffe.Net('pt_net.prototxt', 'exp/'+db+'/save_iter_%d.caffemodel'%params['pt_iter'][0])
163-
print net.params.keys()
164163
for i in xrange(n_layer):
165164
if i == 0:
166165
k = 'd_data'
@@ -176,10 +175,11 @@ def pretrain_main(db, params):
176175

177176
if __name__ == '__main__':
178177
db = 'mnist'
178+
input_dim = 784
179179
#dec.make_mnist_data()
180-
print main(db, {'n_layer':[4], 'dim': [784, 500, 500, 2000, 10],
180+
print main(db, {'n_layer':[4], 'dim': [input_dim, 500, 500, 2000, 10],
181181
'drop': [0.0], 'rate': [0.1], 'step': [20000], 'iter':[100000], 'decay': [0.0000]})
182-
print pretrain_main(db, {'dim': [784, 500, 500, 2000, 10], 'pt_iter': [50000],
182+
print pretrain_main(db, {'dim': [input_dim, 500, 500, 2000, 10], 'pt_iter': [50000],
183183
'drop': [0.2], 'rate': [0.1], 'step': [20000], 'iter':[100000], 'decay': [0.0000]})
184184
os.system("caffe train --solver=ft_solver.prototxt --weights=stack_init_final.caffemodel")
185185

0 commit comments

Comments
 (0)