Tensorflow中的基本加法? [英] Basic addition in Tensorflow?
问题描述
我想编写一个程序,在其中输入一组x1 x2并输出一个y.我可以找到的所有张量流教程都是从图像识别开始的.有人可以通过提供有关我如何在python中执行此操作的代码或教程来帮助我吗?提前致谢.编辑-我计划使用的x1 x2坐标将像1、1,y将是2或4、6,而y将是10.我想为程序提供要学习的数据.我曾尝试从tensorflow网站上学习,但似乎比我想要的要复杂得多.
I want to make a program where I enter in a set of x1 x2 and outputs a y. All of the tensor flow tutorials I can find start with image recognition. Can someone help me by providing me either code or a tutorial on how to do this in python? thanks in advance. edit- the x1 x2 coordinates I was planning to use would be like 1, 1 and the y would be 2 or 4, 6 and the y would be 10. I want to provide the program with data to learn from. I have tried to learn from the tensorflow website but it seemed way more complex that what I wanted.
推荐答案
首先,让我们开始定义张量
First, let's start with defining our Tensors
import tensorflow as tf
a=tf.constant(7)
b=tf.constant(10)
c = tf.add(a,b)
现在,我们有了可以添加两个常量的简单图形.现在,我们需要创建一个会话来运行我们的图形:
Now, we have our simple graph which can add two constants. All we need now is to create a session to run our graph:
simple_session = tf.Session()
value_of_c = simple_session.run(c)
print(value_of_c) # 17
simple_session.close()
这篇关于Tensorflow中的基本加法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!