pytorch / pytorch/vision

Inceptionv3 weight is not consistent with tensorflow

Open
#926 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

I am trying to reproduce the Frechet Inception Distance with Pytorch. The original code uses InceptionV3 trained with Tensorflow. But using the pretrained weight provided by Pytorch, the behavior is much different with Tensorflow version.

After some research I found that the weight is totally different. For example, the first convolution kernel data of Pytorch is:

> dic['Conv2d_1a_3x3.conv.weight'][0,0]
tensor([[-0.2103, -0.3441, -0.0344],
        [-0.1420, -0.2520, -0.0280],
        [ 0.0736,  0.0183,  0.0381]])

While tensorflow is

> x=f['weights'].value
> x.shape
Out[15]: (3, 3, 3, 32)
> x[:,:,0,0]
array([[ 0.01260555, -0.00162022,  0.09091024],
       [-0.10557341, -0.15358226, -0.04656353],
       [-0.16552085, -0.17688492, -0.10908931]], dtype=float32)

I wonder how the weight of Pytorch is obtained. And is there a way of perfectly copying tensorflow's weight to Pytorch?

I noticed there are repo for converting Inceptionv3 to Torch (https://github.com/Moodstocks/inception-v3.torch), but it does not work for Pytorch. Can anyone help me? Thank you very much.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the reported first convolution weights and tensor shapes between the TensorFlow and PyTorch InceptionV3 models. Determine whether the discrepancy comes from weight conversion or model behavior, and document a verified conversion path or the reason the weights cannot match exactly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.