[PyTorch] Datasets & DataLoaders

Datasets & DataLoaders PyTorch provides two data primitives (基本資料型態) that allow you to use pre-loaded datasets as well as your own data, as below: torch.utils.data.Dataset Stores the samples and their corresponding labels Dataset 定義資料的結構並且將其包起來,利如: 一張影像和一個標籤 一張影

[PyTorch] Tensors (張量)

Tensors Tensors are a specialized data structure that are very similar to arrays and matrices. In PyTorch, we use tensors to encode the inputs and outputs of a model, as well as the model’s parameters. 張量 (Tensor) 類似向量或矩陣,他是一個 n-維 (n-dimensional) 的資料型態,像是: 0

[DSA] Matrix Chain Multiplication | Dynamic Programming

Matrix Chain Multiplication Input: a sequence of n matries $(A_1, …, A_n)$ Output: the product of $A_1A_2 … A_n$ 根據 Associative (結合律) 可以將問題重新定義為: Matrix Chain Multiplication Problem 相關說明可參考: Observation Observation Each entry takes $q$ multiplications There are total $pr$ entries Time-Complexity: $\Theta(q)\Theta(pr) = \Theta(pqr)$ Associative (結合