DiffEqML / torchdyn

A PyTorch library entirely dedicated to neural differential equations, implicit models and related numerical methods
https://torchdyn.org
Apache License 2.0
1.36k stars 125 forks source link

Change the computation of nfe from the float to int #72

Closed mrpositron closed 3 years ago

mrpositron commented 3 years ago

The number of function evaluations (nfe) can not be of the float type. Thus, could you change the initialization of the nfe from <0.> to <0>?

In the code snippet below you can see that self.nfe is initialized to <0.>

class DEFunc(nn.Module):
    """Differential Equation Function Wrapper. Handles auxiliary tasks for NeuralDEs: depth concatenation,
    higher order dynamics and forward propagated integral losses.

    :param model: neural network parametrizing the vector field
    :type model: nn.Module
    :param order: order of the differential equation
    :type order: int
   """
    def __init__(self, model, order=1):
        super().__init__()
        self.m, self.nfe,  = model, 0.
        self.order, self.intloss, self.sensitivity = order, None, None
Zymrael commented 3 years ago

It can be helpful to keep float init for certain computations (for example mean nfes across training iterations). Do you have a specific reason for this change?

mrpositron commented 3 years ago

Oh, I see. Thanks!