Beispiel #1
0
    Y_test,
    thresholds,
    batchsize=TEST_BATCHSIZE,
    verbose=True)

g_diffs *= 1000.

# 显示原始网络与带有分支的网络测试精度与运行时间的关系图
visualize.plot_line_tradeoff(g_accs,
                             g_diffs,
                             g_ts,
                             g_exits,
                             g_baseacc,
                             g_basediff,
                             all_samples=False,
                             inc_amt=0.0001,
                             our_label='BranchyLeNet',
                             orig_label='LeNet',
                             xlabel='Runtime(ms)',
                             title='LeNet Gpu',
                             output_path=SAVE_PATH,
                             output_name='lenet_gpu(' +
                             str(TRAIN_NUM_EPOCHES) + ')')
# 将结果保存为csv文件
utils.branchy_save_csv(g_baseacc,
                       g_basediff,
                       g_accs,
                       g_diffs,
                       g_exits,
                       g_ts,
                       filename=CSV_NAME)
                                                      verbose=True)
# g_ts, g_accs, g_diffs, g_exits = utils.screen_leaky(leakyNet, x_test, y_test, thresholds, inc_amt=-0.1,
#                                                     batchsize=TEST_BATCHSIZE, verbose=True)

#convert to ms
g_diffs *= 1000.

# In[ ]:

visualize.plot_line_tradeoff(g_accs,
                             g_diffs,
                             g_ts,
                             g_exits,
                             g_baseacc,
                             g_basediff,
                             all_samples=False,
                             inc_amt=-0.0001000,
                             our_label='BranchyResNet',
                             orig_label='ResNet',
                             xlabel='Runtime (ms)',
                             title='ResNet GPU',
                             output_path='_figs/resnet_gpu.pdf')

# In[ ]:

#CPU
branchyNet.to_cpu()
c_ts, c_accs, c_diffs, c_exits = utils.screen_branchy(branchyNet,
                                                      x_test,
                                                      y_test,
                                                      thresholds,