Codacy Small Bug Fixes:
- cleaned up imports - cleaned up some code - added docstrings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
""" Implementation of adaptive linear layer. """
|
||||
import torch
|
||||
from torch.nn.parameter import Parameter
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import torch
|
||||
from torch.nn.parameter import Parameter
|
||||
|
||||
class AdaptiveReLU(torch.nn.Module):
|
||||
class AdaptiveReLU(torch.nn.Module, Parameter):
|
||||
'''
|
||||
Implementation of soft exponential activation.
|
||||
Shape:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
""" """
|
||||
from torch.utils.data import Dataset, DataLoader
|
||||
import functools
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ class CartesianDomain(Location):
|
||||
pts = chebyshev_roots(n).mul(.5).add(.5).reshape(-1, 1)
|
||||
elif mode == 'grid':
|
||||
pts = torch.linspace(0, 1, n).reshape(-1, 1)
|
||||
elif mode == 'lh' or mode == 'latin':
|
||||
# elif mode == 'lh' or mode == 'latin':
|
||||
elif mode in ['lh', 'latin']:
|
||||
pts = torch_lhs(n, dim)
|
||||
|
||||
pts *= bounds[:, 1] - bounds[:, 0]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
""" Integral class for continous convolution"""
|
||||
import torch
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ from ..utils import check_consistency
|
||||
|
||||
|
||||
class Network(torch.nn.Module):
|
||||
""" Network class with starndard forward method
|
||||
and possibility to pass extra features."""
|
||||
|
||||
def __init__(self, model, extra_features=None):
|
||||
super().__init__()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
""" Module for plotting. """
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
from pina import LabelTensor
|
||||
@@ -43,7 +42,8 @@ class Plotter:
|
||||
proj = '3d' if len(variables) == 3 else None
|
||||
ax = fig.add_subplot(projection=proj)
|
||||
for location in solver.problem.input_pts:
|
||||
coords = solver.problem.input_pts[location].extract(variables).T.detach()
|
||||
coords = solver.problem.input_pts[location].extract(
|
||||
variables).T.detach()
|
||||
if coords.shape[0] == 1: # 1D samples
|
||||
ax.plot(coords[0], torch.zeros(coords[0].shape), '.',
|
||||
label=location)
|
||||
|
||||
Reference in New Issue
Block a user