pnnl / neuromancer

Pytorch-based framework for solving parametric constrained optimization problems, physics-informed system identification, and parametric model predictive control.
https://pnnl.github.io/neuromancer/
Other
913 stars 120 forks source link

FBPINN paper code reproduction problem #174

Closed siwuxei closed 3 months ago

siwuxei commented 3 months ago

Thank you for sharing the source code. I recently read the paper "FINITE BASIS KOLMOGOROV-ARNOLD NETWORKS: DOMAIN DECOMPOSITION FOR DATA-DRIVEN AND PHYSICS-INFORMED PROBLEMS," but it seems there might be an issue with the code.

Taking the file p1_fbkan_vs_kan_noise_data_1d.ipynb as an example, when defining FBPINN, the KANBlock in the neuromancer library does not have the parameter num_domains.

# Neural nets to solve the PDE problem
net_fbkan = blocks.KANBlock(insize=1,
                            outsize=1,
                            hidden_size=[5], # hidden width
                            num_domains=10,  # number of domains for domain decomposition
                            grid_sizes=[5],  # grid size for KAN
                            spline_order=3,  # spline order
                            grid_range=[0,2]
                            ).to(device)

Definition of KANBlock in neuromancer

class KANBlock(Block):
    def __init__(
        self,
        insize,
        outsize,
        num_layers=1,
        hidden_size=None,
        grid_size=5,
        spline_order=3,
        scale_noise=0.1,
        scale_base=1.0,
        scale_spline=1.0,
        enable_standalone_scale_spline=True,
        base_activation=torch.nn.SiLU,
        grid_eps=0.02,
        grid_range=[-1, 1],
    ):
        super().__init__()
        self.in_features = insize
        self.out_features = outsize
        self.kan_layers = nn.ModuleList()
brunopjacob commented 3 months ago

Hi @siwuxei! Thank you for using Neuromancer!

The parameter num_domains is indeed not yet available on the master of Neuromancer, but you can get early access by using the feature/fbkans branch. To do so, you can switch to the branch viagit switch feature/fbkans, and then proceed with the installation from the root of the repository (e.g., pip install -e.). To make sure you have all of the latest features plus the fbkans, I merged the feature/fbkans with the develop this morning, so you should be good to go :)

Please let me know if that doesn't work, I'd be happy to help.

Best wishes, Bruno

siwuxei commented 3 months ago

Hi @siwuxei! Thank you for using Neuromancer!

The parameter num_domains is indeed not yet available on the master of Neuromancer, but you can get early access by using the feature/fbkans branch. To do so, you can switch to the branch viagit switch feature/fbkans, and then proceed with the installation from the root of the repository (e.g., pip install -e.). To make sure you have all of the latest features plus the fbkans, I merged the feature/fbkans with the develop this morning, so you should be good to go :)

Please let me know if that doesn't work, I'd be happy to help.

Best wishes, Bruno

Thanks for your prompt reply! The problem has been solved and the code works well. 🥰