auto_examples/example_demo
Run in Google Colab
Colab
Download Notebook
Notebook
View on GitHub
GitHub
%matplotlib inline
Sphinx Gallery Demo#
This is a simple example demonstrating the Sphinx Gallery integration with the PyTorch Sphinx Theme.
NumPy Arrays#
Let’s create some arrays and demonstrate basic operations.
import numpy as np
First, let’s create some arrays:
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
float64
We can also create arrays with random values:
x = np.random.randn(3, 3)
print(x)
[[-0.54842479 1.68659573 1.07072748]
[-2.01715488 -0.0742827 -0.4233414 ]
[ 0.15631046 0.83281396 0.15244184]]
Plotting with Matplotlib#
The gallery can also display plots:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [1, 4, 2, 3])
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_title('Simple Plot')
plt.show()