美文网首页tensflow
tensorflow入门

tensorflow入门

作者: 松鼠的读书笔记 | 来源:发表于2019-01-27 22:28 被阅读30次

    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深度学习自然语言处理课程

    相关文章

      网友评论

        本文标题:tensorflow入门

        本文链接:https://www.haomeiwen.com/subject/xcnnjqtx.html