tensorflow入门

1、TensorFlow express a numeric computation as a graph

Graph nodes are operations which have any number of inputs and outputs

Graph edges are tensors which flow between nodes

tensorflow计算图

2、Variables, Placeholders & Operations

(1)Variables are stateful nodes which output their current value. State is retained across multiple executions of a graph (mostly parameters)

(2)Placeholders are nodes whose value is fed in at execution time (inputs, labels, …)

(3) Mathematical operations:

① MatMul: Multiply two matrix values.

② Add: Add elementwise (with broadcasting).

③ ReLU: Activate with elementwise rectified linear function.

3、Steps of writing and running programs in TensorFlow

(1)创建tensors (variables)

(2)定义tensors之间的操作

(3)初始化tensors

(4)创建会话

(5)运行会话 

示例代码如下:


》First build a graph using variables and placeholders:

创建计算图

》Then deploy the graph onto a session, which is the execution environment:

执行计算图

4、How to train the model ?

(1)Build a graph  创建计算图

(2)Feedforward / Prediction  前向传播 / 预测

(3)Optimization (gradients and train_step operation)  优化

(4)Initialize a session  初始化会话

(5)Train with session.run(train_step, feed_dict)  运行会话,训练模型

代码示例如下:


定义损失
计算梯度
构建训练步骤
训练模型

5、Variables sharing

变量共享



参考资料:斯坦福CS224N深度学习自然语言处理课程

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容