初学TensorFlow

虽然我觉得总是用别人造的轮子很low,但是如果连造好的轮子都不会用,那就更low了。况且以我小白的身份,没有资格看不上这些牛X的工具。那么好好学习,同时记下来笔记,不设私密也不怕被人笑。


1. TensorFlow初体验

  1. Define placeholders where you'll send inputs
  2. Make symbolic graph: a recipe for mathematical transformation of those placeholders
  3. Compute outputs of your graph with particular values for each placeholder
output.eval({placeholder:value})
s.run(output, {placeholder:value})

和以往熟悉的编程方式不太一样,TensorFlow是基于Computational Graph的。应该是为了适应符号运算而设计的方案。

先定义placeholder, 以后使用的transform就是已定义的placeholder的函数。eval函数或者run函数可以返回给定placeholder情况下的输出。

Anyway,还是更习惯变量这种概念。当然,tersorflow也支持variable。

The inputs and transformations have no value outside function call. This isn't too comfortable if you want your model to have parameters (e.g. network weights) that are always present, but can change their value over time.

Tensorflow solves this with tf.Variable objects.

  • You can assign variable a value at any time in your graph
  • Unlike placeholders, there's no need to explicitly pass values to variables when `s.run(...)`-ing
  • You can use variables the same way you use transformations 

显然,我还是prefer这个Variable对象。

既然是变量,就可以初始化,而不需要像placeholder那样每次调用时传递值。不过用起来总归还是不顺,估计是不习惯符号编程的方式。

* Tensorflow can compute derivatives and gradients automatically using the computation graph.
* True to its name it can manage matrix derivatives.

* Gradients are computed as a product of elementary derivatives via the chain rule.


目前看到一些基本操作,有这样一个基本:

1. 定义placeholder和待优化i变量

2. 定义Loss函数

3. 定义optimizer

4. 迭代run optimizer并监测准确率

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值