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.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Fatos interessantes sobre arrays, matrizes e tensores: o número 3 vai te surpreender
slides:
https://hackmd.io/@melissawm/rkXK894Ad
O que são arrays?
Uma array é uma estrutura de dados que armazena uma coleção de elementos identificados por, pelo menos, um índice ou uma chave. As arrays mantêm uma série de elementos de dados, geralmente do mesmo tamanho e tipo de dados. O índice geralmente utiliza uma sequência de números inteiros, mas o índice pode ter qualquer valor ordinal. Os arranjos podem ser multidimensionais, significando que eles são indexados por um número fixo de números inteiros, por exemplo, por uma sequência finita de quatro números inteiros. Geralmente, arranjos unidimensionais (vetores) e bidimensionais (matrizes) são os mais comuns.
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Por que precisamos de arrays?
Arrays
Arrays contém elementos de tamanho fixo, o que permite guardá-los em um bloco contíguo de memória: (Link)
Se
arr
é uma array com inteiros, earr[0]
está armazenado no endereçox
, entãoarr[i]
está armazenado no endereçox+i*sizeof(int)
Operações matemáticas
Histórico
NumPy: a base da computação científica no Python
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →NumPy: a base da computação científica no Python
ndarray
(array homogêneo n-dimensional)- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Fonte: Harris et al., "Array Programming with NumPy", Nature volume 585, pages 357–362 (2020)
Conceitos básicos: Vetorização
Vetorização é a capacidade de expressar operações em arrays sem especificar o que acontece com cada elemento individual (em outras palavras: sem usar loops!)
Vetorização: Exemplo 1
Como isso acontece?
As arrays do NumPy são eficientes porque
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Fonte: Harris et al., "Array Programming with NumPy", Nature volume 585, pages 357–362 (2020)
Vetorização: Exemplo 2
Vetorização: Exemplo 3
(O que são essas dimensões?)
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →https://www.oreilly.com/library/view/elegant-scipy/9781491922927/ch01.html
Vetorização: Exemplo 4
Vetorização: Exemplo 5
Broadcasting
Permite fazer operações vetoriais de maneira generalizada.
Broadcasting
Representação interna das ndarrays no NumPy
.transpose
, views,.reshape
, slices…)- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →Fonte: Harris et al., "Array Programming with NumPy", Nature volume 585, pages 357–362 (2020)
Algumas operações criam views, outras criam cópias:
https://webcourses.ucf.edu/courses/1249560/pages/python-lists-vs-numpy-arrays-what-is-the-difference
Interoperabilidade: Protocolos
buffer protocol
Da documentação:
Retorna 1 if
obj
suporta a interface de buffer, 0 caso contrário.Interoperabilidade: Protocolos
Protocolos servem como interfaces para os dados.
__array__
__array_ufunc__
Outras implementações
PyTorch
Blog post sobre implementação do PyTorch
Dask
CuPy
Pontos importantes
Obrigada!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →@melissawm