TensorFlow2.0矩阵与向量的加减乘实例

作者:缘高情定 时间:2023-12-30 13:21:00 

1、矩阵加法使用


a = np.random.random((3,3))
b = np.random.randint(0,9,(3,3))
ad = tf.add(a,b)

2、矩阵乘法注意


# tensorflow 使用矩阵乘法都必须使用相同类型的数据,否则报错。
a = np.random.random((5,3))
b = np.random.randint(0,9,(3,6))
c = tf.tensordot(a.astype(np.float),b.astype(np.float),axes=1)
print(c.numpy())

3、矩阵减法


a = np.random.random((3,3))
b = np.random.randint(0,9,(3,3))
ad = tf.subtract(a,b)

4、数的除法


d = tf.divide(9*2,3)
print(d.numpy())

自动化学习。

来源:https://www.cnblogs.com/wuzaipei/p/10956118.html

标签:TensorFlow2.0,矩阵,向量,加减乘
0
投稿

猜你喜欢

  • python查找特定名称文件并按序号、文件名分行打印输出的方法

    2023-11-27 03:35:35
  • 联邦学习论文解读分散数据的深层网络通信

    2023-09-06 00:07:37
  • Python requests库参数提交的注意事项总结

    2021-11-18 19:40:18
  • VUE3中watch监听使用实例详解

    2024-05-29 22:42:16
  • Mysql树形递归查询的实现方法

    2024-01-14 08:05:16
  • python学习实操案例(四)

    2023-10-12 04:43:57
  • ASP运行在IIS6 500错误解决办法

    2011-04-19 11:15:00
  • centos7.3 安装mysql5.7.18的详细教程

    2024-01-12 18:57:00
  • python为图片和PDF去水印详解

    2023-06-28 14:09:43
  • python中selenium库的基本使用详解

    2022-02-13 08:52:21
  • PyQt5每天必学之像素图控件QPixmap

    2022-04-05 04:42:54
  • php简单获取复选框值的方法

    2023-11-15 20:57:28
  • Python使用numpy模块实现矩阵和列表的连接操作方法

    2023-02-17 21:05:41
  • python用pyecharts画矩形树图实例

    2022-12-20 21:42:04
  • 使用python实现链表操作

    2021-07-29 23:30:38
  • 解决os.path.isdir() 判断文件夹却返回false的问题

    2022-11-07 18:11:37
  • Python利用shutil模块实现文件夹的复制删除与裁剪

    2023-12-19 04:16:23
  • Mac下Supervisor进程监控管理工具的安装与配置

    2023-06-12 14:33:12
  • Python操作Access数据库基本步骤分析

    2024-01-18 22:32:20
  • 用Python实现等级划分

    2022-10-11 23:45:21
  • asp之家 网络编程 m.aspxhome.com