This commit is contained in:
tqchen 2015-01-13 14:41:37 -08:00
parent c127f9650c
commit 532575b752
2 changed files with 26 additions and 1 deletions

25
test/test_local_recover.py Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/python
import rabit
import numpy as np
rabit.init(with_mock = True)
rank = rabit.get_rank()
n = 10
nround = 3
data = np.ones(n) * rank
version, model, local = rabit.load_checkpoint(True)
if version == 0:
model = np.zeros(n)
local = np.ones(n)
else:
print '[%d] restart from version %d' % (rank, version)
for i in xrange(version, nround):
res = rabit.allreduce(data + model+local, rabit.SUM)
print '[%d] iter=%d: %s' % (rank, i, str(res))
model = res
local[:] = i
rabit.checkpoint(model, local)
rabit.finalize()

View File

@ -223,7 +223,7 @@ def load_model__(ptr, length):
length: int length: int
the length of buffer the length of buffer
""" """
data = (ctypes.c_char * length).from_address(addressof(ptr.contents)) data = (ctypes.c_char * length).from_address(ctypes.addressof(ptr.contents))
return pickle.loads(data.raw) return pickle.loads(data.raw)
def load_checkpoint(with_local = False): def load_checkpoint(with_local = False):