TensorFlow程序分析(profile)实战

本文介绍了如何在TensorFlow中进行程序分析,包括建立模型、加载数据、统计模型参数量、浮点运算数,以及详细分析模型的内存占用和运行时间。通过使用TensorFlow的profile工具,为优化模型性能提供了实用的建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导入必要的包

import os
import tempfile

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

建立模型

batch_size = 100

# placeholder
inputs = tf.placeholder(tf.float32, [batch_size, 784])
targets = tf.placeholder(tf.float32, [batch_size, 10])

# model
fc_1_out = tf.layers.dense(inputs, 500, activation=tf.nn.sigmoid)
fc_2_out = tf.layers.dense(fc_1_out, 784, activation=tf.nn.sigmoid)
logits = tf.layers
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值