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.15531032 0.13848024 -0.16200623]
[ 0.52148955 0.06202172 0.06135281]
[-1.59317493 -1.18269839 1.59056716]]
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()