当前位置:网站首页>TensorFlow中的Tensor是什么?
TensorFlow中的Tensor是什么?
2020-11-06 20:53:00 【Alili丶前端大爆炸】
Tensor(张量)
“张量”一词最初由威廉·罗恩·哈密顿在1846年引入。对,就是那个发明四元数的哈密顿:

-
Tensor实际上就是一个多维数组(multidimensional array)
-
Tensor的目的是能够创造更高维度的矩阵、向量。

色彩的例子
彩色图像文件(RGB)一般都会处理成3-d tensor,每个2d array中的element表示一个像素,R代表Red,G代表Green,B代表Blue

多维数组

把三维张量画成一个立方体:

更高维的张量:

初始化一个向量
0维
tf.tensor(1).print();
1维
tf.tensor([1, 2, 3, 4]).print();
// or
tf.tensor1d([1, 2, 3]).print();
2维
tf.tensor([[1, 2], [3, 4]]).print();
// or
tf.tensor2d([[1, 2], [3, 4]]).print();
3维
tf.tensor([[[1], [2]], [[3], [4]]]).print();
// or
tf.tensor3d([[[1], [2]], [[3], [4]]]).print();
4维
tf.tensor([[[[1], [2]], [[3], [4]]]]).print();
// or
tf.tensor4d([[[[1], [2]], [[3], [4]]]]).print();
5维
tf.tensor([[[[[1], [2]], [[3], [4]]]]]).print();
// or
tf.tensor5d([[[[[1], [2]], [[3], [4]]]]]).print();
6维
tf.tensor([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print();
// or
tf.tensor6d([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print();
更多文章请关注我的博客 Alili丶前端大爆炸 订阅号:
Alili丶前端大爆炸
版权声明
本文为[Alili丶前端大爆炸]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4000748/blog/4667574
边栏推荐
- Using Es5 to realize the class of ES6
- Save the file directly to Google drive and download it back ten times faster
- How to encapsulate distributed locks more elegantly
- I've been rejected by the product manager. Why don't you know
- Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
- 一篇文章教会你使用HTML5 SVG 标签
- NLP model Bert: from introduction to mastery (1)
- Vue.js Mobile end left slide delete component
- 使用 Iceberg on Kubernetes 打造新一代云原生数据湖
- The difference between Es5 class and ES6 class
猜你喜欢

Flink的DataSource三部曲之二:内置connector

一篇文章带你了解HTML表格及其主要属性介绍

From zero learning artificial intelligence, open the road of career planning!

Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】

Use of vuepress

熬夜总结了报表自动化、数据可视化和挖掘的要点,和你想的不一样

Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!

钻石标准--Diamond Standard

关于Kubernetes 与 OAM 构建统一、标准化的应用管理平台知识!(附网盘链接)
![[C / C + + 1] clion configuration and running C language](/img/5b/ba96ff4447b150f50560e5d47cb8d1.jpg)
[C / C + + 1] clion configuration and running C language
随机推荐
100元扫货阿里云是怎样的体验?
Wiremock: a powerful tool for API testing
[JMeter] two ways to realize interface Association: regular representation extractor and JSON extractor
Brief introduction and advantages and disadvantages of deepwalk model
Solve the problem of database insert data garbled in PL / SQL developer
PN8162 20W PD快充芯片,PD快充充电器方案
Summary of common string algorithms
High availability cluster deployment of jumpserver: (6) deployment of SSH agent module Koko and implementation of system service management
Did you blog today?
做外包真的很难,身为外包的我也无奈叹息。
使用 Iceberg on Kubernetes 打造新一代云原生数据湖
Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
EOS创始人BM: UE,UBI,URI有什么区别?
git rebase的時候捅婁子了,怎麼辦?線上等……
What is the difference between data scientists and machine learning engineers? - kdnuggets
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
After reading this article, I understand a lot of webpack scaffolding
深度揭祕垃圾回收底層,這次讓你徹底弄懂她
What is the side effect free method? How to name it? - Mario
Not long after graduation, he earned 20000 yuan from private work!