ok
This commit is contained in:
parent
c127f9650c
commit
532575b752
25
test/test_local_recover.py
Executable file
25
test/test_local_recover.py
Executable 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()
|
||||
@ -223,7 +223,7 @@ def load_model__(ptr, length):
|
||||
length: int
|
||||
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)
|
||||
|
||||
def load_checkpoint(with_local = False):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user