tensorflow超参数优化_tensorflow优化

4f9b21012ca30ef2a4da131649d10cb4.png

1 常用优化

  官方提供的优化请参考官方文档:https://tensorflow.google.cn/guide/performance/overview?hl=zh-cn,列出的都是些最基本的常用优化方法,效果明显,更细的优化就不具体介绍了,像算子粒度的优化.

1.1 增加并发量提高算子计算图

  提高算子和算子间的并发量对提高性能最明显,简单有效,是最常用的优化方法,尤其对CPU计算来说,下面给出三个修改并发量的参数,CPU计算时一定不要忘记这三个参数.

config.proto

// Map from device type name (e.g., "CPU" or "GPU" ) to maximum
// number of devices of that type to use. If a particular device
// type is not found in the map, the system picks an appropriate
// number.
map<string, int32> device_count = 1;

// The execution of an individual op (for some op types) can be
// parallelized on a pool of intra_op_parallelism_threads.
// 0 means the system picks an appropriate number.
int32 intra_op_parallelism_threads = 2;

// Nodes that perform blocking operations are enqueued on a pool of
// inter_op_parallelism_threads available in each process.
//
// 0 means the system picks an appropriate number.
//
// Note that the first Session created in the process sets the
// number of threads for all future sessions unless use_per_session_threads is
// true or session_inter_op_thread_pool is configured.
int32 inter_op_parallelism_threads = 5;
解释:
1)device_count, 告诉tf Session使用CPU数量上限,如果你的CPU数量较多,可以适当加大这个值;

2) inter_op_parallelism_threads和intra_op_parallelism

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值