Vector¶
Create¶
| Action | Code | Details |
|---|---|---|
| From matrix |
|
Type of vector depends on shape of the matrix? |
| From 1D array |
|
Create column vector¶
| Action | Code | Details |
|---|---|---|
| Declare column vector of size N |
|
|
| Declare column vector with values |
|
|
| Declare column vector filled with zeros |
|
|
| Declare column vector filled with value |
|
Create row vector¶
| Action | Code | Details |
|---|---|---|
| Declare row vector of size N |
|
|
| Declare row vector with values |
|
Create special vectors with constraints¶
| Action | Code | Details |
|---|---|---|
| Declare ordered vector of size N |
|
|
| Declare positive ordered vector of size N |
|
|
| Declare simplex of size N (proportions vector that sum up to 1) |
|
|
| Declare unit vector |
|
|
| Declare optional vector in parameter block, conditional on include |
|
Useful for disabling model feature to save memory |
Properties¶
| Action | Code | Details |
|---|---|---|
| Length (number of elements) |
|
Extract¶
| Action | Code | Details |
|---|---|---|
| Get element at index i |
|
|
| Get element at index i as vector |
|
|
| Get index of largest value |
|
Derive¶
Map¶
Element-wise operations.
| Action | Code | Details |
|---|---|---|
| Square elements |
|
|
| Square root elements |
|
|
| Different multiplication per element |
|
|
| Different power per element |
|
only for strictly positive v |
| Different power per element |
|
|
| Cumulative sum |
|
|
| Softmax |
|
|
| Log-softmax |
|
|
| Dot product |
|
|
| Dot product (self) |
|
v * v, or sum(v .* v) |
| Dot product |
|
Grow¶
| Action | Code | Details |
|---|---|---|
| Append element to column vector |
|
|
| Prepend element to column vector |
|
|
| Append element to row vector |
|
|
| Prepend element to row vector |
|
Shrink¶
| Action | Code | Details |
|---|---|---|
| First n elements (head) |
|
|
| Last n elements (tail) |
|
|
| Slice |
|
|
| Slice of length n |
|
Reshape¶
| Action | Code | Details |
|---|---|---|
| Transpose |
|
Convert¶
| Action | Code | Details |
|---|---|---|
| To row vector |
|
|
| Transpose: from row to column vector, or vice versa |
|
|
| To n by m matrix, column-major order |
|
|
| To matrix with 1 row or column |
|
Depends on whether v is a row or column vector |
| To 1D array |
|