Hello, TensorFlow!

一站式学习体验:O‘Reilly在线教育平台 本文将详细介绍O'Reilly在线教育平台的特色与优势。通过该平台,用户可以接触到书籍、视频、现场在线培训课程等多种学习资源,这些资源来源于O'Reilly及其200多个合作伙伴。读者可以访问oreilly.com/online-learning了解更多相关信息,体验集中的在线学习解决方案。 阅读详情

Hello, TensorFlow! - O'Reilly Media
https://www.oreilly.com/learning/hello-tensorflow

【Presenting “Hello, TensorFlow!” Again
http://planspace.org/20161005-presenting_hello_tensorflow_again/】

Hello, TensorFlow!

Building and training your first TensorFlow graph from the ground up.

June 20, 2016


The TensorFlow project is bigger than you might realize. The fact that it's a library for deep learning, and its connection to Google, has helped TensorFlow attract a lot of attention. But beyond the hype, there are unique elements to the project that are worthy of closer inspection:

  • The core library is suited to a broad family of machine learning techniques, not “just” deep learning.
  • Linear algebra and other internals are prominently exposed.
  • In addition to the core machine learning functionality, TensorFlow also includes its own logging system, its own interactive log visualizer, and even its own heavily engineered serving architecture.
  • The execution model for TensorFlow differs from Python's scikit-learn, or most tools in R.

Cool stuff, but—especially for someone hoping to explore machine learning for the first time—TensorFlow can be a lot to take in.

Get O'Reilly's AI newsletter

How does TensorFlow work? Let's break it down so we can see and understand every moving part. We'll explore the data flow graph that defines the computations your data will undergo, how to train models with gradient descent using TensorFlow, and how TensorBoard can visualize your TensorFlow work. The examples here won't solve industrial machine learning problems, but they'll help you understand the components underlying everything built with TensorFlow, including whatever you build next!

Names and execution in Python and TensorFlow

The way TensorFlow manages computation is not totally different from the way Python usually does. With both, it's important to remember, to paraphrase Hadley Wickham, that an object has no name (see Figure 1). In order to see the similarities (and differences) between how Python and TensorFlow work, let’s look at how they refer to objects and handle evaluation.

Names “have” objects, rather than the reverse Figure 1. Names “have” objects, rather than the reverse. Image courtesy of Hadley Wickham, used with permission.

The variable names in Python code aren't what they represent; they're just pointing at objects. So, when you say in Python that foo = [] and bar = foo, it isn't just that foo equals bar; foo is bar, in the sense that they both point at the same list object.

>>> foo = []
>>> bar = foo
>>> foo == bar
## True
>>> foo is bar
## True

You can also see that id(foo) and id(bar) are the same. This identity, especially with mutable data structures like lists, can lead to surprising bugs when it's misunderstood.

Internally, Python manages all your objects and keeps track of your variable names and which objects they refer to. The TensorFlow graph represents another layer of this kind of management; as we’ll see, Python names will refer to objects that connect to more granular and managed TensorFlow graph operations.

SAFARI

Join Safari. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more 

When you enter a Python expression, for example at an interactive interpreter or Read Evaluate Print Loop (REPL), whatever is read is almost always evaluated right away. Python is eager to do what you tell it. So, if I tell Python to foo.append(bar), it appends right away, even if I never use foo again.

A lazier alternative would be to just remember that I said foo.append(bar), and if I ever evaluate foo at some point in the future, Python could do the append then. This would be closer to how TensorFlow behaves, where defining relationships is entirely separate from evaluating what the results are.

TensorFlow separates the definition of computations from their execution even further by having them happen in separate places: a graph defines the operations, but the operations only happen within a session. Graphs and sessions are created independently. A graph is like a blueprint, and a session is like a construction site.

Back to our plain Python example, recall that foo and bar refer to the same list. By appending bar into foo, we've put a list inside itself. You could think of this structure as a graph with one node, pointing to itself. Nesting lists is one way to represent a graph structure like a TensorFlow computation graph.

>>> foo.append(bar)
>>> foo
## [[...]]

Real TensorFlow graphs will be more interesting than this!

The simplest TensorFlow graph

To start getting our hands dirty, let’s create the simplest TensorFlow graph we can, from the ground up. TensorFlow is admirably easier to install than some other frameworks. The examples here work with either Python 2.7 or 3.3+, and the TensorFlow version used is 0.8.

>>> import tensorflow as tf

At this point TensorFlow has already started managing a lot of state for us. There's already an implicit default graph, for example. Internally, the default graph lives in the _default_graph_stack, but we don't have access to that directly. We use tf.get_default_graph().

>>> graph = tf.get_default_graph()

The nodes of the TensorFlow graph are called “operations,” or “ops.” We can see what operations are in the graph with graph.get_operations().

>>> graph.get_operations()
## []

Currently, there isn't anything in the graph. We’ll need to put everything we want TensorFlow to compute into that graph. Let's start with a simple constant input value of one.

VIDEO

Up and Running with Deep Learning

>>> input_value = tf.constant(1.0)

That constant now lives as a node, an operation, in the graph. The Python variable name input_value refers indirectly to that operation, but we can also find the operation in the default graph.

>>> operations = graph.get_operations()
>>> operations
## [<tensorflow.python.framework.ops.Operation at 0x1185005d0>]
>>> operations[0].node_def
## name: "Const"
## op: "Const"
## attr {
##   key: "dtype"
##   value {
##     type: DT_FLOAT
##   }
## }
## attr {
##   key: "value"
##   value {
##     tensor {
##       dtype: DT_FLOAT
##       tensor_shape {
##       }
##       float_val: 1.0
##     }
##   }
## }

TensorFlow uses protocol buffers internally. (Protocol buffers are sort of like a Google-strength JSON.) Printing the node_def for the constant operation above shows what's in TensorFlow's protocol buffer representation for the number one.

People new to TensorFlow sometimes wonder why there's all this fuss about making “TensorFlow versions” of things. Why can't we just use a normal Python variable without also defining a TensorFlow object? One of the TensorFlow tutorials has an explanation:

To do efficient numerical computing in Python, we typically use libraries like NumPy that do expensive operations such as matrix multiplication outside Python, using highly efficient code implemented in another language. Unfortunately, there can still be a lot of overhead from switching back to Python every operation. This overhead is especially bad if you want to run computations on GPUs or in a distributed manner, where there can be a high cost to transferring data.

TensorFlow also does its heavy lifting outside Python, but it takes things a step further to avoid this overhead. Instead of running a single expensive operation independently from Python, TensorFlow lets us describe a graph of interacting operations that run entirely outside Python. This approach is similar to that used in Theano or Torch.

TensorFlow can do a lot of great things, but it can only work with what's been explicitly given to it. This is true even for a single constant.

If we inspect our input_value, we see it is a constant 32-bit float tensor of no dimension: just one number.

>>> input_value
## <tf.Tensor 'Const:0' shape=() dtype=float32>

Note that this doesn't tell us what that number is. To evaluate input_valueand get a numerical value out, we need to create a “session” where graph operations can be evaluated and then explicitly ask to evaluate or “run” input_value. (The session picks up the default graph by default.)

>>> sess = tf.Session()
>>> sess.run(input_value)
## 1.0

It may feel a little strange to “run” a constant. But it isn't so different from evaluating an expression as usual in Python; it's just that TensorFlow is managing its own space of things—the computational graph—and it has its own method of evaluation.

The simplest TensorFlow neuron

Now that we have a session with a simple graph, let's build a neuron with just one parameter, or weight. Often, even simple neurons also have a bias term and a non-identity activation function, but we'll leave these out.

The neuron's weight isn't going to be constant; we expect it to change in order to learn based on the “true” input and output we use for training. The weight will be a TensorFlow variable. We'll give that variable a starting value of 0.8.

>>> weight = tf.Variable(0.8)

You might expect that adding a variable would add one operation to the graph, but in fact that one line adds four operations. We can check all the operation names:

>>> for op in graph.get_operations(): print(op.name)
## Const
## Variable/initial_value
## Variable
## Variable/Assign
## Variable/read

We won't want to follow every operation individually for long, but it will be nice to see at least one that feels like a real computation.

>>> output_value = weight * input_value

Now there are six operations in the graph, and the last one is that multiplication.

>>> op = graph.get_operations()[-1]
>>> op.name
## 'mul'
>>> for op_input in op.inputs: print(op_input)
## Tensor("Variable/read:0", shape=(), dtype=float32)
## Tensor("Const:0", shape=(), dtype=float32)

This shows how the multiplication operation tracks where its inputs come from: they come from other operations in the graph. To understand a whole graph, following references this way quickly becomes tedious for humans. TensorBoard graph visualization is designed to help.

How do we find out what the product is? We have to “run” the output_value operation. But that operation depends on a variable: weight. We told TensorFlow that the initial value of weight should be 0.8, but the value hasn't yet been set in the current session. The tf.initialize_all_variables() function generates an operation which will initialize all our variables (in this case just one) and then we can run that operation.

>>> init = tf.initialize_all_variables()
>>> sess.run(init)

The result of tf.initialize_all_variables() will include initializers for all the variables currently in the graph, so if you add more variables you'll want to use tf.initialize_all_variables() again; a stale init wouldn't include the new variables.

Now we're ready to run the output_value operation.

>>> sess.run(output_value)
## 0.80000001

Recall that's 0.8 * 1.0 with 32-bit floats, and 32-bit floats have a hard timewith 0.8; 0.80000001 is as close as they can get.

See your graph in TensorBoard

Up to this point, the graph has been simple, but it would already be nice to see it represented in a diagram. We'll use TensorBoard to generate that diagram. TensorBoard reads the name field that is stored inside each operation (quite distinct from Python variable names). We can use these TensorFlow names and switch to more conventional Python variable names. Using tf.mul here is equivalent to our earlier use of just * for multiplication, but it lets us set the name for the operation.

>>> x = tf.constant(1.0, name='input')
>>> w = tf.Variable(0.8, name='weight')
>>> y = tf.mul(w, x, name='output')

TensorBoard works by looking at a directory of output created from TensorFlow sessions. We can write this output with a SummaryWriter, and if we do nothing aside from creating one with a graph, it will just write out that graph.

The first argument when creating the SummaryWriter is an output directory name, which will be created if it doesn't exist.

>>> summary_writer = tf.train.SummaryWriter('log_simple_graph', sess.graph)

Now, at the command line, we can start up TensorBoard.

$ tensorboard --logdir=log_simple_graph

TensorBoard runs as a local web app, on port 6006. (“6006” is “goog” upside-down.) If you go in a browser to localhost:6006/#graphs you should see a diagram of the graph you created in TensorFlow, which looks something like Figure 2.

A TensorBoard visualization of the simplest TensorFlow neuron Figure 2. A TensorBoard visualization of the simplest TensorFlow neuron.

Making the neuron learn

Now that we’ve built our neuron, how does it learn? We set up an input value of 1.0. Let's say the correct output value is zero. That is, we have a very simple “training set” of just one example with one feature, which has the value one, and one label, which is zero. We want the neuron to learn the function taking one to zero.

Currently, the system takes the input one and returns 0.8, which is not correct. We need a way to measure how wrong the system is. We'll call that measure of wrongness the “loss” and give our system the goal of minimizing the loss. If the loss can be negative, then minimizing it could be silly, so let's make the loss the square of the difference between the current output and the desired output.

>>> y_ = tf.constant(0.0)
>>> loss = (y - y_)**2

So far, nothing in the graph does any learning. For that, we need an optimizer. We'll use a gradient descent optimizer so that we can update the weight based on the derivative of the loss. The optimizer takes a learning rate to moderate the size of the updates, which we'll set at 0.025.

>>> optim = tf.train.GradientDescentOptimizer(learning_rate=0.025)

The optimizer is remarkably clever. It can automatically work out and apply the appropriate gradients through a whole network, carrying out the backward step for learning.

Let's see what the gradient looks like for our simple example.

>>> grads_and_vars = optim.compute_gradients(loss)
>>> sess.run(tf.initialize_all_variables())
>>> sess.run(grads_and_vars[1][0])
## 1.6

Why is the value of the gradient 1.6? Our loss is error squared, and the derivative of that is two times the error. Currently the system says 0.8 instead of 0, so the error is 0.8, and two times 0.8 is 1.6. It's working!

For more complex systems, it will be very nice indeed that TensorFlow calculates and then applies these gradients for us automatically.

Let's apply the gradient, finishing the backpropagation.

>>> sess.run(optim.apply_gradients(grads_and_vars))
>>> sess.run(w)
## 0.75999999  # about 0.76

The weight decreased by 0.04 because the optimizer subtracted the gradient times the learning rate, 1.6 * 0.025, pushing the weight in the right direction.

Instead of hand-holding the optimizer like this, we can make one operation that calculates and applies the gradients: the train_step.

>>> train_step = tf.train.GradientDescentOptimizer(0.025).minimize(loss)
>>> for i in range(100):
>>>     sess.run(train_step)
>>> 
>>> sess.run(y)
## 0.0044996012

Running the training step many times, the weight and the output value are now very close to zero. The neuron has learned!

Training diagnostics in TensorBoard

We may be interested in what's happening during training. Say we want to follow what our system is predicting at every training step. We could print from inside the training loop.

>>> sess.run(tf.initialize_all_variables())
>>> for i in range(100):
>>>     print('before step {}, y is {}'.format(i, sess.run(y)))
>>>     sess.run(train_step)
>>> 
## before step 0, y is 0.800000011921
## before step 1, y is 0.759999990463
## ...
## before step 98, y is 0.00524811353534
## before step 99, y is 0.00498570781201

This works, but there are some problems. It's hard to understand a list of numbers. A plot would be better. And even with only one value to monitor, there's too much output to read. We're likely to want to monitor many things. It would be nice to record everything in some organized way.

Luckily, the same system that we used earlier to visualize the graph also has just the mechanisms we need.

We instrument the computation graph by adding operations that summarize its state. Here, we'll create an operation that reports the current value of y, the neuron's current output.

>>> summary_y = tf.scalar_summary('output', y)

When you run a summary operation, it returns a string of protocol buffer text that can be written to a log directory with a SummaryWriter.

>>> summary_writer = tf.train.SummaryWriter('log_simple_stats')
>>> sess.run(tf.initialize_all_variables())
>>> for i in range(100):
>>>     summary_str = sess.run(summary_y)
>>>     summary_writer.add_summary(summary_str, i)
>>>     sess.run(train_step)
>>> 

Now after running tensorboard --logdir=log_simple_stats, you get an interactive plot at localhost:6006/#events (Figure 3).

A TensorBoard visualization of a neuron’s output against training iteration number Figure 3. A TensorBoard visualization of a neuron’s output against training iteration number.

Flowing onward

Here's a final version of the code. It's fairly minimal, with every part showing useful (and understandable) TensorFlow functionality.

import tensorflow as tf

x = tf.constant(1.0, name='input')
w = tf.Variable(0.8, name='weight')
y = tf.mul(w, x, name='output')
y_ = tf.constant(0.0, name='correct_value')
loss = tf.pow(y - y_, 2, name='loss')
train_step = tf.train.GradientDescentOptimizer(0.025).minimize(loss)

for value in [x, w, y, y_, loss]:
    tf.scalar_summary(value.op.name, value)

summaries = tf.merge_all_summaries()

sess = tf.Session()
summary_writer = tf.train.SummaryWriter('log_simple_stats', sess.graph)

sess.run(tf.initialize_all_variables())
for i in range(100):
    summary_writer.add_summary(sess.run(summaries), i)
    sess.run(train_step)

The example we just ran through is even simpler than the ones that inspired it in Michael Nielsen's Neural Networks and Deep Learning. For myself, seeing details like these helps with understanding and building more complex systems that use and extend from simple building blocks. Part of the beauty of TensorFlow is how flexibly you can build complex systems from simpler components.

If you want to continue experimenting with TensorFlow, it might be fun to start making more interesting neurons, perhaps with different activation functions. You could train with more interesting data. You could add more neurons. You could add more layers. You could dive into more complex pre-built models, or spend more time with TensorFlow's own tutorials and how-to guides. Go for it!

Thanks to Paco Nathan, Ben Lorica, and Marie Beaugureau for nudging this post toward existence. Thanks to Henry Chen, Dennis Leung, and Paul Gulley at Deep Learning Analytics, and the DC Machine Learning Journal Club for providing valuable feedback on early versions. Thanks again to Marie Beaugureau and Jenn Webb for dramatically improving the quality of the final version.

 

This post is also available as an Oriole Tutorial.













tensorflow_helloworld_demo.py例子 官方例子,深度学习专用,机器学习专用,代码简单,一看就会(tensorflow helloworld demo) 立即下载

相关推荐

Sparse4Dv3

instance_feature也设置为nn.Parameter。修正分支2*(linear->relu->linear->relu->layernorm)->linear->scale,分类分枝2*(linear->relu->layernorm)->linear(256,9),质量评估分枝2*(linear->relu->layernorm)->linear(256,2)。每组两类instance,1是加上范围(-x,x)内均匀分布噪声,2是加上(-2x,-x)U(x,2x)范围内均匀分布噪声。

yuanl15的博客 1351

【亲测免费】 探索O'Reilly学习之旅 —— 免费试用神器oreilly-trial

探索O'Reilly学习之旅 —— 免费试用神器oreilly-trial 在技术探索的道路上,O'Reilly Learning平台以其丰富的资源成为了众多开发者和学习者的宝库。然而,获取其试用账号往往是一道门槛。今天,我们带来一款开源工具——oreilly-trial,它巧妙地解决了这个问题,让你轻松获得10天免费学习机会。 项目介绍 oreilly-trial是一款简洁高效的工具,旨在为用户...

gitblog_00839的博客 947

浮点数运算的陷阱与启示:FP16加法器/乘法器开发中的常见误区

本文深入探讨FP16加法器和乘法器开发中的常见误区,包括FP16格式解析、阶码对齐陷阱、尾数运算风险及规格化处理。通过Verilog实战代码展示防御性编程技巧,帮助开发者避免边界条件处理和异常状态管理中的错误,提升硬件设计的可靠性和效率。

dell8的博客 249

只要15美元,畅享O'Reilly所有在线学习资源!

O'Reilly是世界著名信息技术图书出版公司,它为读者提供了丰富的在线学习资源,但是个人会员499美元/年,是一笔不小的开销。笔者发现通过注册ACM会员,只要15美元/年就可以...

机器学习与系统 4288

保姆级教程:用Kalibr搞定Intel D435i三目(RGB+双目)相机联合标定,附完整ROSbag录制避坑指南

本文详细介绍了如何使用Kalibr工具对Intel D435i三目相机(RGB+双目)进行高精度联合标定,包括硬件准备、ROSbag录制技巧、Kalibr标定实战及结果验证。特别针对实际工程中的常见问题提供了解决方案,帮助开发者提升SLAM和三维重建等应用的精度。

weixin_42524762的博客 405

本地部署ComfyUI:开源AI生图与视频生成完整实战指南

在生成式AI应用快速普及的今天,云端工具常受制于排队、积分和素材管理等问题,而本地化部署正成为开发者与创作者的高效替代方案。其核心思路是基于开源工作流引擎,将图像生成、视频生成与后期处理整合到同一套可离线运行的系统中。ComfyUI作为当前最受关注的节点式工作流平台,凭借灵活的模块组合和强大的自定义能力,降低了从图像模型调用到视频扩展的工程门槛。本文从环境配置与依赖安装入手,系统讲解如何部署ComfyUI、加载Checkpoint模型、跑通文生图基础流程,再通过自定义节点接入视频生成能力,同时介绍API批量

weixin_30985047的博客 562

Tensorflow(一)Hello TensorFlow

重要概念: 一、基础概念 张量:使用张量(tensor)表示数据,用“阶”表示张量的维度。关于这一点需要展开一下 0阶张量称为标量,表示单独的一个数 1阶张量称为向量, 表示一个一维数组 2阶张量称为矩阵,表示一个二维数组 …… 数据流:数据流(data stream)是一组有序,有起点...

viafcccy的博客 654

vesta软件_分子动力学计算实战:利用 OVITO 软件找弗伦克尔缺陷和位错环分析

今天继续和大家分享这篇纯分子动力学(MD)的 Nat. Comm. 文章(DOI:10.1038/s41467-018-07102-3)。上期推文(从一篇 Nat. Comm. 学习经典分子动力学基本知识和相关软件基本操作 (一)),我们借用该文章的 fig.1 简单介绍了如何用文中所提到的 LAMMPS 软件来实现材料中级联碰撞过程。但是,想完整的展示类似该文章的 fig.1,单纯利用...

weixin_39524842的博客 5982

【深度学习】hello tensorflow:安装TensorFlow(on mac m3)、tensorflow集成到idea、第一个tensorflow程序(以及tf2适配版本tf1)

【机器学习】hello tensorflow:安装TensorFlow(on mac m3)、tensorflow集成到idea、第一个tensorflow程序(以及tf2适配版本tf1)

hiliang521的博客 3109

Valgrind 从入门到精通:内存调试和性能分析

Valgrind 提供了强大的 API,允许开发者编写自定义的检查工具。通过扩展 Valgrind,可以针对特定场景实现更精准的检测。

大模型大数据攻城狮的专栏 1217

RK3588 开启多窗口

这样就支持多窗口了。

tzj1058756809的博客 267

Hello_TensorFlow!

第一趟车,粗发啦~ 正式学习之前,我们得先把TensorFlow安装好。原谅博主的不专业,为了能让最多人能够接触到TensorFlow,我使用的是Windows版本的Python3.6.1(欢呼吧!)使用的是PyCharm Community Edition(python编程神器,使用第三方库的时候真的很省事,谁用谁知道)按照如下图所示,注意,博主的TF安装的是CPU版的(之后需要大量计算的时候

longer_tju的博客 869

【2026年华为暑期实习(非AI方向(通软&嵌软&测试&算法&数据科学))-4月8日-第一题- 包裹的编码】(题目+思路+Java&C++&Python解析+在线测试)

摘要:该问题要求将给定的十进制整数N转换为混合进制编码字符串,并处理回文检测。首先根据N的符号位确定编码首位(0或1),然后按输入的进制序列依次对N的绝对值进行取余和整除操作,得到编码数组。将数组元素转换为字母后生成字符串,若字符串为回文则添加"(palindrome)"后缀;否则输出最长回文子串(字典序最小)。算法采用中心扩展法检测回文,时间复杂度为O(L²),空间复杂度为O(L),其中L为字符串长度。

m0_73659489的博客 129

Tensorflow基础 Hello World!

Tensorflow输出Hello World!Tensorflow 1.X:Tensorflow 2 :Tensorflow 2 中执行Tensorflow1.X代码 : Tensorflow 1.X: import tensorflow as tf #创建一个常值运算,将作为一个节点加入默认计算图中 hello=tf.constant('Hello World!') #创建一个tf会话 sess=tf.Session() print(sess.run(hello)) sess.close() 输出b’

wanjialin的博客 966

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

敲代码啦!——Tensorflow_01_Hello,World!

1、使用Tensorflow输出Hello,World #导入tensorflow import tensorflow as tf #创建一个常量张量 hello = tf.constant('Hello,World') #Session封装了被执行操作和Tensor计算的环境 sess = tf.Session() #Python3使用 print() Python2使用print pri...

vselfdom 532

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

TensorFlow学习笔记1:Hello TensorFlow!

根据 https://github.com/aymericdamien/TensorFlow-Examples 学习TensorFlow import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) 其中第二行定义了常量hello,在Ten

sherry_颖的博客 515

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

使用tensorflow编写第一个程序Hello TensorFlow!

前提是将相应的软件安装好,环境配置好!!! 1、部分功能简介 第一步打开Anaconda软件,选择home,将编译文件切换到tensorflow36; 然后点击Jupyter noetbook。 将在电脑默认浏览器弹出一个页面。 先在桌面上建一个文件夹(DL)创建的代码文件可以放里面,文件夹可以随便选。 打开DL文件夹,在右上角点击new ,new一个python3的文件。 其中绿色表示已连接...

weixin_44254920的博客 801

用Tensorflow说-Hello World!

Tenserflow实现HelloWorld! Tenserflow作为开放源代码的软件库,可用于进行高性能数值计算,并不是一门单独的编程语言而是一个计算框架,但对于刚入门环境配了两天的小白我来说,还是先从HelloWorld开始吧。 首先先打开jupyter检查一下自己是否安装好了Tenserflow,且是什么版本的,因为1.x和2.x版本有巨大改变,所以必须注意一下。 import tenso...

Jason 343

TensorFlow 的 hello world!入门首选

import tensorflow as tf import matplotlib.pyplot as plt import numpy as np # 训练数据 x_data = np.linspace(-0.5,0.5,200)[:,np.newaxis] noise = np.random.normal(0,0.02,x_data.shape) y_data = np.square(x_...

weixin_36060730的博客 183

TensorFlow(01)—Hello, TensorFlow!

搭建ubuntu虚拟机,使用的版本是ubuntu-16.04-desktop-amd64 搭建ssh服务,配置为桥接网络 apt-get 更新时候遇到的错误 sudo apt-get update 1.Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) sudo rm /v

facing的专栏 225

conda tensorflow_TensorFlow从0到1 - 1 - Hello, TensorFlow!

Hello,TensorFlow!在学习任何新的编程语言时,我们都会在第一时间完成Hello World,以宣告自己开发环境的完美搭建。TensorFlow也不例外。TensorFlow充分考虑了各种软/硬件平台上的安装,本篇记录了在我的笔电Win 10环境下TensorFlow 1.1的安装(在国内这应该是最常见的一种个人环境)并打印出“Hello TensorFlow !”的过程。确认安装选项...

weixin_39784972的博客 117

使用Tensorflow打印“Hello World!”

系统:Windows 10 x64和Python 3.8 在Anaconda3->Jupyter Notebook中代码及运行效果如下: import tensorflow as tf tf.compat.v1.disable_eager_execution() h=tf.constant("Hello World!") sess=tf.compat.v1.Session() print(sess.run(h).decode()) 在VSCode中运行的代码和效果如下: import tensor

假技术Po主 590

用聊天记录训练微信机器人只要20分钟:WeClone数字克隆完整部署指南

想让微信机器人用你的口吻聊天,还不用从零学机器学习吗?WeClone 就是一站式方案:用你真实的微信聊天记录对大语言模型做微调(让模型在你的数据上额外训练一轮),产出一个说话习惯像你本人的数字克隆。本指南面向零背景读者,把“数据 → 训练 → 部署到微信”拆成三步走,不中断的话大约 20 分钟跑完。 ## 🧭 先想清楚:通用聊天机器人够用吗 这一节回答的是:为什么值得拿自己的记录训练一个,而

gitblog_02058的博客 495

Hello, TensorFlow!--转自O'Reilly网站

本文转自O'Reilly,作者Aaron Schumacher。 原文链接如下:https://www.oreilly.com/learning/hello-tensorflow Hello, TensorFlow! Building and training your first TensorFlow graph from the ground up. By Aaron Schum

LucyGill的博客 612

Tensorflow2.0学习(一)Hello World!

TensorFlow2.0初体验吧。之前搞定了cuda环境,所以是用支持GPU的版本跑的,网上的教程大多是用tf1.x写的,所以想自己看着官网的文档来写一写2.0的教程。 安装十分简单: pip install tensorflow-gpu==2.0.0-beta1 新版本TensorFlow已经支持cuda10.0(谢天谢地)。 下面是官网给的示例代码: impor...

竹夭公子的博客 4337

TensorFlow学习笔记2:"Hello World!"

本文参考TF官方入门程序链接: https://tensorflow.google.cn/tutorials/keras/basic_classification 推荐直接看以上链接中的官方教程,如果无法打开该链接可以直接看以下内容,以下为官方内容的一个搬运,以保证本系列的完整性,便于自己学习使用。 本教程会训练一个对服饰(例如运动鞋和衬衫)图像进行分类的神经网络模型。 本教程使用 tf.kera...

TracelessLe的专栏 1550
上一篇: 论numpy中matrix 和 array的区别
下一篇: 逻辑斯蒂回归与梯度下降算法
yusisc
博客等级 码龄10年 22粉丝 63原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值