首页 技术 正文
技术 2022年11月14日
0 收藏 484 点赞 2,247 浏览 1641 个字
import tensorflow as tfa = tf.ones([1, 5, 5, 3])
a.shapea[0][0]
numpy : 索引a = tf.random.normal([4, 28, 28, 3])
a.shapea[1].shapea[1, 2].shape
a[1][2][3].shape
a[1, 2, 3, 2].shape
一维切片
a = tf.range(10)
aa[-1:]
a[-2:]
a[:2]
a[:-1]
多维切片
a = tf.random.normal([4, 28, 28, 3])
a.shapea[0].shapea[0, :, :, :].shapea[0, 1, :, :].shapea[:, :, :, 0].shapea[:, :, :, 2].shapea[:, 0, :, :].shape
步长::step
a = tf.random.normal([4, 28, 28, 3])
a.shapea[0:2, :, :, :].shapea[:, 0:28:2, 0:28:2, :].shapea[:, :14, :14, :].shapea[:, 14:, 14:, :].shapea[:, ::2, ::2, :].shape
倒序::-1
a = tf.range(4)
aa[::-1]a[::-2]a[2::-2]
省略号...
a = tf.random.normal([2, 4, 28, 28, 3])
a.shapea[0].shapea[0, :, :, :, :].shapea[0, ...].shapea[:, :, :, :, 0].shapea[..., 0].shapea[0, ..., 2].shapea[1, 0, ..., 0].shape
gathera = tf.random.normal([4, 35, 8])
a.shapetf.gather(a, axis=0, indices=[2, 3]).shapea[2:4].shapetf.gather(a, axis=0, indices=[2, 1, 3, 0]).shapetf.gather(a, axis=1, indices=[2, 3, 7, 9, 16]).shapetf.gather(a, axis=2, indices=[2, 3, 7]).shapeaa = tf.gather(a,axis,[several students])
aaa = tf.gather(aa,axis,[several subjects])
gather_nda = tf.random.normal([4, 35, 8])
a.shapetf.gather_nd(a, [0]).shape # [[0],[],[]]tf.gather_nd(a, [0, 1]).shapetf.gather_nd(a, [0, 1, 2]).shapetf.gather_nd(a, [[0, 1, 2]]).shapetf.gather_nd(a, [[0, 0], [1, 1]]).shapetf.gather_nd(a, [[0, 0], [1, 1], [2, 2]]).shape# 第一个班级第一个学生的第一门课
# 第二个班级第二个学生的第二门课
# 第三个班级第三个学生的第三门课
tf.gather_nd(a, [[0, 0, 0], [1, 1, 1], [2, 2, 2]]).shapetf.gather_nd(a, [[[0, 0, 0], [1, 1, 1], [2, 2, 2]]]).shape
boolean_mask
a = tf.random.normal([4, 28, 28, 3])
a.shapetf.boolean_mask(a, mask=[True, True, False, False]).shapetf.boolean_mask(a, mask=[True, True, False], axis=3).shapea = tf.ones([2, 3, 4])
a.shape# [2,3],还剩下4,三个True,因此是3*4True
tf.boolean_mask(a, mask=[[True, False, False], [False, True, True]]).shape
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,997
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,356
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,139
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848