Skip to content

Possible bug in AdaptivePool #641

Description

@yardenas

The following code seems to fail

import numpy as np
from torch import nn
import torch
import jax
import equinox as eqx

print(torch.__version__, eqx.__version__)

random_input = jax.random.normal(jax.random.PRNGKey(1), (10, 90, 90, 50))

ppool = torch.nn.AdaptiveAvgPool3d(4)
jpool = eqx.nn.AdaptiveAvgPool3d(4)
random_input_torch = torch.tensor(np.asarray(random_input))
pp = ppool(random_input_torch)
jj = jpool(random_input)

assert np.allclose(np.asarray(pp), np.asarray(jj)), print(np.asarray(jj) - np.asarray(pp))

Not sure if I'm missing something here, I just stumbled upon this trying to convert an Equinox model to pytorch.

I tried going over AdaptivePool but couldn't really figure out the problem. Same thing happens when using 2d pooling btw. Happy to make a PR fixing the issue with some guidance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions