Author Archives: wdengquantum.me
PyTorch Fundamentals (Part \(1\))
Problem: Illustrate some of the basic fundamentals involved in using the PyTorch deep learning library. In particular, discuss the attributes of PyTorch tensors (e.g. dtype, CPU/GPU devices, etc.), how to generate random PyTorch tensors with/without seeding, and operations that can … Continue reading
Self-Attention in Transformers
Problem: Explain how the transformer architecture works at a mathematical level (e.g. as outlined in the Attention Is All You Need paper). Solution: \[\Delta\mathbf x_i=V\text{softmax}\left(\frac{K^T\mathbf q_i}{\sqrt{n_{qk}}}\right)\] where \(K=(\mathbf k_1,…,\mathbf k_N)\in\mathbf R^{n_{qk}\times N}\) and \(V=(\mathbf v_1,…,\mathbf v_N)\in\mathbf R^{n_e\times N}\) are key … Continue reading
JAX Fundamentals (Part \(1\))
JAX_tutorial $\textbf{Problem}$: What is JAX? $\textbf{Solution}$: JAX = Autograd + XLA, where Autograd refers to automatic differentiation, and XLA refers to accelerated linear algebra (compiler developed by Google that optimizes code to run fast on GPUs/TPUs). At a high level, … Continue reading
Monte Carlo Methods
Problem: Distinguish between Las Vegas methods and Monte Carlo methods. Solution: Both are umbrella terms referring to broad classes of methods that draw (repeatedly) from (not necessarily i.i.d.) random variables to compute the value of some deterministic variable. Here, “compute” … Continue reading
Differential Geometry
Problem: What does it mean for a topological space \(X\) to be locally homeomorphic to a topological space \(Y\)? Hence, what does it mean for a topological space \(X\) to be locally Euclidean? Solution: \(X\) is said to be locally … Continue reading
Support Vector Machines
Problem: Explain how a hard-margin support vector machine would perform binary classification. Solution: Conceptually, it’s simple. Given a training set of \(N\) feature vectors \(\mathbf x_1,…,\mathbf x_N\in\mathbf R^n\) each associated with some binary target label \(y_1,…,y_N\in\{-1,1\}\) (notice the \(2\) binary … Continue reading
Numerical Computation
Problem: In numerical computation, what are the \(2\) main kinds of rounding error? Solution: Overflow error (\(N\approx\infty\)) but perhaps even more dangerous is underflow error (\(\varepsilon\approx 0\)) which are in some sense inverses of each other: \[0=\frac{1}{\infty}\] Problem: Explain how … Continue reading
Information Theory & Inference
Problem: Draw a schematic of a binary symmetric channel (BSC) with bit flip probability \(p_f\). Solution: Classically, one has: On the other hand, taking a more quantum perspective, in the computational basis \((|0\rangle,|1\rangle)\) one might define a binary symmetric channel … Continue reading
SVD, Pseudoinverse, and PCA
Problem: State the form of the singular value decomposition (SVD) of an arbitrary linear operator \(X:\mathbf C^m\to\mathbf C^n\). Solution: The SVD of \(X\) is given by: \[X=U_2\Sigma U^{\dagger}_1\] where \(U_1\in U(m)\) and \(U_2\in U(n)\) are unitary operators and \(\Sigma:\mathbf C^m\to\mathbf … Continue reading
Hartree-Fock Method
Problem: The Hamiltonian of an atom may be written in the perturbative form: \[H=H_0+V\] what are \(H_0\) and \(V\)? Solution: If the atom has \(N\) electrons and atomic number \(Z\) (if neutral then \(Z=N\) but here one can also allow … Continue reading