import tensorflow as tf

a = tf.ones([2, 2])
a
tf.norm(a)
tf.sqrt(tf.reduce_sum(tf.square(a)))
a = tf.ones([4, 28, 28, 3])
a.shape
tf.norm(a)
tf.sqrt(tf.reduce_sum(tf.square(a)))
b = tf.ones([2, 2])
tf.norm(b)
tf.norm(b, ord=2, axis=1)
tf.norm(b, ord=1)
# 列为整体
tf.norm(b, ord=1, axis=0)
# 行为整体
tf.norm(b, ord=1, axis=1)
reduce,操作可能会有减维的功能,如[2,2],对行求max,会变成[2]
a = tf.random.normal([4, 10])
tf.reduce_min(a), tf.reduce_max(a), tf.reduce_mean(a)
# 对某一行求max
tf.reduce_min(a, axis=1), tf.reduce_max(a, axis=1), tf.reduce_mean(a, axis=1)
a.shape
tf.argmax(a).shape
# 返回index
tf.argmax(a)
# 对第1维作用
tf.argmin(a).shape
# 对第2维作用
tf.argmin(a, axis=1).shape
a = tf.constant([1, 2, 3, 2, 5])
b = tf.range(5)
tf.equal(a, b)
res = tf.equal(a, b)
# 对True和False转换为1和0
tf.reduce_sum(tf.cast(res, dtype=tf.int32))
a = tf.random.normal([2, 3])
a
pred = tf.cast(tf.argmax(a, axis=1), dtype=tf.int32)
pred.shape
y = tf.constant([2, 1])
y
tf.equal(y, pred)
correct = tf.reduce_sum(tf.cast(tf.equal(y, pred), dtype=tf.int32))
correct
correct / 2
用于去重
a = tf.range(5)
a
# 返回索引
tf.unique(a)
a = tf.constant([4, 2, 2, 4, 3])
a
res = tf.unique(a)

最新文章

  1. Packet for query is too large(1767212 > 1048576)mysql在存储图片时提示图片过大
  2. JavaScript作用域闭包简述
  3. 蓝桥杯 算法训练 Torry的困惑(基本型)(水题,筛法求素数)
  4. GIS开源软件大全
  5. 反射工具类——ReflectUtils
  6. webstorm注释写出的提示
  7. Centos4.3安装MySQL-python-1.2.3,出现error: command 'gcc' failed with exit status 1
  8. 手机浏览器下IScroll中click事件
  9. PHP静态延迟绑定简单示例
  10. vi 编辑器跳转到指定行数
  11. Dapper源码学习和源码修改
  12. maven 搭建 SpringMVC + MyBatis(1)
  13. SAP 发送邮件 面向对象
  14. Javascript实现简单跨域调用
  15. Mysql之库表操作(胖胖老师)
  16. 【DOS】Win7系统文件夹名太长无法删除问题的解决
  17. NB卡开卡注意事项【转】
  18. Python-cookie,session
  19. Keras 构建DNN 对用户名检测判断是否为非法用户名(从数据预处理到模型在线预测)
  20. 腾讯首批 5000 人群,现在加入【FineUI总群】,极速体验!

热门文章

  1. Python基础week2
  2. OBS Studio 24.0 RC1 发布 – 有大惊喜
  3. vSphere 计算vMotion的迁移原理
  4. git 的那点东西,随心记
  5. imput placeholder 移动端不居中问题
  6. 使用 json 模块,使json数据格式与Python字典dict数据格式互相转换,获取数据更加方便
  7. Eclipse 不能调试的问题
  8. uniapp 小程序 flex布局 v-for 4栏展示
  9. List<string>绑定到DataGridView控件
  10. Centos 8下命令行界面支持鼠标