Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: model save interval = config.verbose and code sync script #1359

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions recognition/partial_fc/mxnet/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,20 @@ def __call__(self, param):


class CallBackModelSave(object):
def __init__(self, symbol, model, prefix, rank):
def __init__(self, symbol, model, prefix, rank, save_interval=10000):
self.symbol = symbol
self.model = model
self.prefix = prefix
self.max_step = config.max_update
self.rank = rank
self.save_interval = save_interval

def __call__(self, param):
num_update = param.num_update

if num_update in [
self.max_step - 10,
] or (num_update % 10000 == 0 and num_update > 0):
] or (num_update % self.save_interval == 0 and num_update > 0):

# params
arg, aux = self.model.get_export_params()
Expand All @@ -121,12 +122,12 @@ def __call__(self, param):

if self.rank == 0:
mx.model.save_checkpoint(prefix=self.prefix + "_average",
epoch=0,
epoch=num_update / self.save_interval,
symbol=_sym,
arg_params=new_arg,
aux_params=new_aux)
mx.model.save_checkpoint(prefix=self.prefix,
epoch=0,
epoch=num_update / self.save_interval,
symbol=_sym,
arg_params=arg,
aux_params=aux)
Expand Down
11 changes: 11 additions & 0 deletions recognition/partial_fc/mxnet/sync_code.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -xu

file=$1
hosts=$( cat $file | cut -d " " -f 1 )

for host in $hosts
do
rsync -az ~/insightface* $host:~/insightface
done
2 changes: 1 addition & 1 deletion recognition/partial_fc/mxnet/train_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def train_net():
if not config.debug and local_rank == 0:
cb_vert = CallBackVertification(esym, train_module)
cb_speed = CallBackLogging(rank, size, prefix_dir)
cb_save = CallBackModelSave(save_symbol, train_module, prefix, rank)
cb_save = CallBackModelSave(save_symbol, train_module, prefix, rank, save_interval=config.verbose)
cb_center_save = CallBackCenterSave(memory_bank)

def call_back_fn(params):
Expand Down