coursera上tensorflow教程

记住 placeholder就是开辟一个空间,在运行session的时候赋值。有文档的哦

1. Writing and running programs in TensorFlow has the following steps:

  1. Create Tensors (variables) that are not yet executed/evaluated.
  2. Write operations between those Tensors.
  3. Initialize your Tensors.
  4. Create a Session.
  5. Run the Session. This will run the operations you'd written above. 

To summarize, remember to initialize your variables, create a session and run the operations inside the session.

Writing and running programs in TensorFlow has the following steps:

  1. Create Tensors (variables) that are not yet executed/evaluated.
  2. Write operations between those Tensors.
  3. Initialize your Tensors.
  4. Create a Session.
  5. Run the Session. This will run the operations you'd written above. 

To summarize, you how know how to:

Create placeholdersSpecify the computation graph corresponding to operations you want to computeCreate the sessionRun the session, using a feed dictionary if necessary to specify placeholder variables' values. 

目前学到的有:

1.tf.constant(value,name=“*”) 创造一个叫*的常量值为value。

要运行一个程序,先建session,例

Note that there are two typical ways to create and use sessions in tensorflow:

Method 1:

sess = tf.Session()
# Run the variables initialization (if needed), run the operations
result = sess.run(..., feed_dict = {...})
sess.close() # Close the session

Method 2:

with tf.Session() as sess: 
    # run the variables initialization (if needed), run the operations
    result = sess.run(..., feed_dict = {...})
    # This takes care of closing the session for you :)

tf.placeholder(tf.float32,name="z")创造叫z的量,类型是float32,看名字就是预留空间,可以先不给该值赋量。

 cost = sess.run(cost,feed_dict=({z:logits,y:labels})) 这是对之前没有幅值的两个量z,y进行幅值用的feed_dict

2.有用的函数

tf.matmul计算矩阵乘法,tf.add计算加法。

tf.global_variables_initializer(). 参数的初始化。

tf.nn.sigmoid_cross_entropy_with_logits(logits = z,  labels = y)计算cost所用。

tf.one_hot(labels,C,1)labels是指输入的值,C表示可表示的类数,该类为1其余为0。就是自动将y从原始数据转成只有一个1的表示,例如

TensorFlow架构深度学习步骤:

1.Your first task is to create placeholders for X and Y. This will allow you to later pass your training data in when you run your session. 

2.Your second task is to initialize the parameters in tensorflow.

3.You will now implement the forward propagation module in tensorflow. The function will take in a dictionary of parameters and it will complete the forward pass. 

4.compute the cost,It is important to know that the "logits" and "labels" inputs of tf.nn.softmax_cross_entropy_with_logits are expected to be of shape (number of examples, num_classes). We have thus transposed Z3 and Y for you.Besides, tf.reduce_mean basically does the summation over the examples.

5.Backward propagation & parameter updates

Tensorflow is a programming framework used in deep learningThe two main object classes in tensorflow are Tensors and Operators. When you code in tensorflow you have to take the following steps:

  • Create a graph containing Tensors (Variables, Placeholders ...) and Operations (tf.matmul, tf.add, ...)
  • Create a session
  • Initialize the session
  • Run the session to execute the graph

You can execute the graph multiple times as you've seen in model()The backpropagation and optimization is automatically done when running the session on the "optimizer" object.

如果对你有所帮助,谢谢您的鼓励^_^

红包还不收?

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值