* Adding title kwarg for plotter class

* Create tutorial for Fourier Feature Embedding
* Update doc for tutorials
This commit is contained in:
Monthly Tag bot
2024-06-07 18:06:42 +02:00
committed by Nicola Demo
parent 4b64998f45
commit e514969a43
10 changed files with 1030 additions and 2 deletions

View File

@@ -235,7 +235,7 @@ class FourierFeatureEmbedding(torch.nn.Module):
size = (input_dimension,
output_dimension // 2),
requires_grad = False
)
) * self.sigma
def forward(self, x):
"""
@@ -248,7 +248,7 @@ class FourierFeatureEmbedding(torch.nn.Module):
# compute random matrix multiplication
out = torch.mm(x, self._matrix)
# return embedding
return torch.cat([torch.cos(out), torch.sin(out)], dim=-1)
return torch.cat([torch.cos(2*torch.pi*out), torch.sin(2*torch.pi*out)], dim=-1)
@property

View File

@@ -168,6 +168,7 @@ class Plotter:
method="contourf",
res=256,
filename=None,
title=None,
**kwargs,
):
"""
@@ -186,6 +187,8 @@ class Plotter:
Default is 'contourf'.
:param int res: The resolution, aka the number of points used for
plotting in each axis. Default is 256.
:param str title: The title for the plot. If None, the plot
is shown without a title. Default is None.
:param str filename: The file name to save the plot. If None, the plot
is shown using the setted matplotlib frontend. Default is None.
"""
@@ -241,6 +244,9 @@ class Plotter:
)
plt.tight_layout()
if title is not None:
plt.title(title)
if filename:
plt.savefig(filename)
plt.close()