tensorflow学习之路(一):变量、常量、占位符、图、会话等基本概念介绍

在使用常量、变量等之前必须先导入tensorflow包

import tensorflow as tf

import numpy as np

1、常量 --constant

例如:    a = tf.constant(3)                b= tf.constant(9)

2、变量  --Variable

例如:     x = tf.Variable(0.)                y = tf.Variable(0.)

#注意变量的英文首字母是大写的,变量必须要初始化之后才能使用,并且不能直接打印出变量,需要在会话中才能打印出数据。

3、常用操作符和基本数学函数

 
  1. # 算术操作符:+ - * / %
  2. tf.add(x, y, name= None) # 加法(支持 broadcasting)
  3. tf. subtract (x, y, name= None ) # 减法
  4. tf. multiply (x, y, name= None ) # 乘法
  5. tf. divide (x, y, name= None ) # 浮点除法, 返回浮点数(python3 除法)
  6. tf.mod(x, y, name= None) # 取余
  7. # 幂指对数操作符:^ ^2 ^0.5 e^ ln
  8. tf. pow (x, y, name= None ) # 幂次方
  9. tf.square(x, name= None) # 平方
  10. tf.sqrt(x, name= None)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值