近年來多維陣列的應用越來越廣泛。從機器學習到資料分析甚至到科學運算都可以看到多維陣列的身影。但是它背後的原理都像是黑魔法一樣;broadcasting、view、transpose、reshape 的機制摸也摸不著。但是它其實沒有那麼難!?40 分鐘帶你走玩一遭可以回家自幹 :3先備知識
能理解中階C++語法(模板、STL)熟悉陣列使用者
SITCON 2020 共筆
SITCON 2020
2020
共筆
難。
R2
歡迎大家來到SITCON 2020 ヽ(✿゚▽゚)ノ
共筆入口:https://hackmd.io/@SITCON/2020
手機版請點選上方 按鈕展開議程列表。
請從這裡開始
張安邦/marty1885
Hierarchical Temporal Memory
一個基於於生物學的 AI 模型
講者開發的,歡迎打星星
高興能HTM實作
支援 CPU+GPU
Python Binding
社群內三大實作之一
用張量表達資料
tensor
Working on DL support!
int arr1[4] = {0,1,2,3};
int arr2[4] = {0,1,2,3};
int res[4];
for (int i = 0; i < 4; i++) {
res[i] = arr1[i] + arr2[i];
}
// 好麻煩
// 還有資安問題
// use template & operation overloading
template <typename T>
struct tensor
{
tensor() =
tensor(size_t size)
:storage()
,size_(size)
{}
size_t size()
};
Access element from a tensor
How to reshape the tensor
tensor<int> &
{{1,2},
{3,4}}
a.data()[1] (int) 2
T & operator[](shape coord){
return somehow_get_value(coord);
}
如何用 2D index 的方式存取?
T & operator[](){
}
用 array[{1,2}] 來存取元素
Numpy則是: array[1,2]
int num[3][4] = {
{1,2,3,4}
{5,6,7,8}
{9,}
}
Now instead of evaulating shape[j] every time
Take 1D tensor<int>
for example
shape
Too complex for a talk
Talk to me later
Special views!
Transpose
2 | 4 | -1 |
---|---|---|
-10 | 5 | 11 |
18 | -7 | 6 |
2 | -10 | 18 |
---|---|---|
4 | 5 | -7 |
-1 | 11 | 6 |
reverse the stride!
reshape
you literally just recompute the stride
easy and simple
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing