Cheatsheet in TensorFlow

Fundamental Data Types in TensorFlow

You can write TensorFlow applications in a number of different languages, such as Python, C++, and Java. But no matter which language you use, you need to be familiar with a series of TensorFlow-specific data types:

  • Tensors and placeholders: A tensor is an instance of the Tensorclass, and it serves as a general-purpose multidimensional array. A placeholder is also a Tensor, but instead of being initialized in code, it receives data from a session that will be valid during one execution of the session. Placeholders make it possible to update a tensor’s content from one session execution to the next.
  • Graphs: A graph is a container similar to a list or a tuple. Only one graph can be active at a time, and when you code an operation that accepts tensors or variables, the tensors, variables, and operation are stored as elements in the graph. When you create an optimizer and call its minimizemethod, TensorFlow stores the resulting operation in the graph.
  • Sessions. Graphs store operations, but they can’t perform operations by themselves. Instead, you need to create a session and call its runmethod. If you call runwith a tensor or operation, the method will execute the operations in the graph needed to obtain the desired result.
  • Optimizers. The goal of machine learning is to refine a mathematical model of a real-world system until it resembles the system as closely as possible. This refinement process is called optimization, and researchers have devised many optimization methods. TensorFlow supports many of these algorithms and provides an optimizer class for each. Regardless of the class, you can obtain an optimization operation by calling the optimizer’s minimizemethod.
  • Variables. Unlike tensors and placeholders, a variable is an instance of the Variableclass. Its primary purpose is to contain data to be updated during the optimization process. For example, if your application models a system with a straight line, you’ll store the line’s slope and y-intercept as variables. But before you can use variables t
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值