1. 磐创AI-开放猫官方网站首页
  2. 资源干货
  3. GitHub

EffectiveTensorflow:Tensorflow 教程和最佳实践

Tensorflow和其他数字计算库(如numpy)之间最明显的区别在于Tensorflow中的操作是符号。 这是一个强大的概念,允许Tensorflow进行所有类型的事情(例如自动区分),这些命令式的库(例如numpy)是不可能的。 但它也是以更难掌握为代价的。 我们在这里的尝试揭示了Tensorflow,并为更有效地使用Tensorflow提供了一些指导方针和最佳实践。

The most striking difference between Tensorflow and other numerical computation libraries such as numpy is that operations in Tensorflow are symbolic. This is a powerful concept that allows Tensorflow to do all sort of things (e.g. automatic differentiation) that are not possible with imperative libraries such as numpy. But it also comes at the cost of making it harder to grasp. Our attempt here is demystify Tensorflow and provide some guidelines and best practices for more effective use of Tensorflow.

Let’s start with a simple example, we want to multiply two random matrices. First we look at an implementation done in numpy:

[code lang=text]
import numpy as np

x = np.random.normal(size=[10, 10])
y = np.random.normal(size=[10, 10])
z = np.dot(x, y)

print(z)
[/code]

Now we perform the exact same computation this time in Tensorflow:

[code lang=text]
import tensorflow as tf

x = tf.random_normal([10, 10])
y = tf.random_normal([10, 10])
z = tf.matmul(x, y)

sess = tf.Session()
z_val = sess.run(z)

print(z_val)
[/code]

项目地址:https://github.com/vahidk/EffectiveTensorflow

原创文章,作者:fendouai,如若转载,请注明出处:https://panchuang.net/2017/08/14/tensorflow-tutorials-and-best-practices/

发表评论

登录后才能评论

联系我们

400-800-8888

在线咨询:点击这里给我发消息

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息