Created by: ceci3
- add median stop
example:
from paddleslim.nas import SANAS
from paddleslim.nas.early_stop import MedianStop
steps = 10
epochs = 7
config = [('MobileNetV2Space')]
sanas = SANAS(config, server_addr=("", 8732), save_checkpoint=None)
### add for early stop
earlystop = MedianStop(sanas, 2)
for step in range(steps):
archs = sanas.next_archs()[0]
for epoch in range(epochs):
for data in train_reader():
loss = archs(data)
for data in test_reader():
loss = archs(data)
avg_cost = np.mean(loss)
### add for early stop
status = earlystop.get_status(step, avg_cost, epochs)
if status == 'BAD':
break;
sanas.reward(avg_cost)