当前位置:网站首页>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
边栏推荐
- Python3 e-learning case 4: writing web proxy
- 一篇文章带你了解CSS 分页实例
- Save the file directly to Google drive and download it back ten times faster
- Keyboard entry lottery random draw
- Using consult to realize service discovery: instance ID customization
- [C / C + + 1] clion configuration and running C language
- Brief introduction of TF flags
- Analysis of etcd core mechanism
- How to use parameters in ES6
- How to select the evaluation index of classification model
猜你喜欢

Natural language processing - BM25 commonly used in search

Working principle of gradient descent algorithm in machine learning

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

Summary of common algorithms of linked list

Existence judgment in structured data

I'm afraid that the spread sequence calculation of arbitrage strategy is not as simple as you think

Brief introduction of TF flags

axios学习笔记(二):轻松弄懂XHR的使用及如何封装简易axios

数据产品不就是报表吗?大错特错!这分类里有大学问

Did you blog today?
随机推荐
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
git rebase的時候捅婁子了,怎麼辦?線上等……
The difference between Es5 class and ES6 class
每个前端工程师都应该懂的前端性能优化总结:
容联完成1.25亿美元F轮融资
从海外进军中国,Rancher要执容器云市场牛耳 | 爱分析调研
一篇文章带你了解HTML表格及其主要属性介绍
I've been rejected by the product manager. Why don't you know
Natural language processing - wrong word recognition (based on Python) kenlm, pycorrector
Filecoin主网上线以来Filecoin矿机扇区密封到底是什么意思
Programmer introspection checklist
vue-codemirror基本用法:实现搜索功能、代码折叠功能、获取编辑器值及时验证
Classical dynamic programming: complete knapsack problem
Analysis of react high order components
一篇文章带你了解CSS 渐变知识
Skywalking series blog 2-skywalking using
Summary of common algorithms of binary tree
NLP model Bert: from introduction to mastery (2)
至联云分享:IPFS/Filecoin值不值得投资?
Windows 10 tensorflow (2) regression analysis of principles, deep learning framework (gradient descent method to solve regression parameters)