tensorflow / tensorflow/models
MobileNet V2 Checkpoint and Frozen Weights are different
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
- Tensorflow 1.4
- MobileNet V2 Model [mobilenet_v2_1.4_224]:
https://storage.googleapis.com/mobilenet_v2/checkpoints/mobilenet_v2_1.4_224.tgz
When I compare the weights using inspect_chekpoint.py of the saved checkpoint and frozen model in the link above, I found these weights different.
Could you please either point me to the right checkpoint or show me how I can reproduce the uploaded pb file given the uploaded ckpt? Can anybody explain?
Steps to reproduce the behavior.
- print the tensors in the saved PB file
- python3-tf inspect_checkpoint.py --file_name mobilenet_v2_1.4_224.ckpt --all_tensors --all_tensor_names --print_options
I expected that the weights in both cases match. However, when I looked at the frozen graph, the tensor names are different than the CKPT + The weight values are different.
The weights of the first Conv2D in MobileNet V2 Frozen model *.pb:
b = sess.graph.get_tensor_by_name('Const_90:0')
print(sess.run(b))
[[[[ 3.63144325e-21 -1.53564215e-01 5.87016307e-02 ... -2.33790655e-22
4.65681143e-02 1.95376700e-20]
[ 1.40816645e-21 -2.91468084e-01 -2.10783452e-01 ... 1.46516628e-20
3.80147174e-02 -2.55226723e-20]
[ 1.48280415e-21 -7.76203051e-02 1.39918834e-01 ... 1.51932544e-20
3.39615010e-02 -4.00863002e-20]]
[[ 3.84989648e-21 -3.66540849e-01 7.27460757e-02 ... 3.47890072e-21
5.25703132e-02 1.92614143e-20]
[ 5.38812092e-22 -5.92921913e-01 -5.07344484e-01 ... 1.32889700e-20
4.21342626e-02 -2.65618584e-20]
[ 1.03662230e-21 -1.87227950e-01 4.41064775e-01 ... 1.71226678e-20
3.64077874e-02 -3.21012769e-20]]
[[ 3.53092101e-21 -7.02582672e-02 7.45330155e-02 ... 1.87887876e-21
4.04618904e-02 2.68340258e-21]
[-1.14299596e-22 -1.27847672e-01 -2.23108515e-01 ... 1.44942933e-20
2.88494304e-02 -3.83389167e-20]
[ 7.80365441e-22 -1.34209124e-02 1.52571887e-01 ... 1.66269491e-20
2.17234865e-02 -3.83998534e-20]]]
[[[ 2.30000053e-21 -3.04481294e-02 6.36594519e-02 ... 8.24343642e-22
4.50458936e-02 4.31667272e-20]
[ 2.32348172e-23 -3.43866087e-02 -1.89307258e-01 ... 8.95076066e-21
3.67962979e-02 1.61209327e-20]
[-2.92352836e-22 -1.52167561e-03 1.38033256e-01 ... 1.48729126e-20
3.31422128e-02 -9.21370352e-22]]
[[ 2.19106594e-21 -2.31754422e-01 5.91165982e-02 ... 1.39377520e-21
5.17838001e-02 3.80243780e-20]
[ 8.23272848e-23 -3.64212513e-01 -5.00747800e-01 ... 1.28172274e-20
4.17063311e-02 4.32664534e-21]
[-1.44959161e-22 -7.46969506e-02 4.50695395e-01 ... 1.67590750e-20
3.68075483e-02 -1.08077908e-20]]
[[ 1.69945469e-21 -2.49620136e-02 5.00051156e-02 ... 4.60027329e-21
3.88296768e-02 1.55418788e-20]
[-1.03572797e-21 -6.27202466e-02 -2.27639630e-01 ... 1.19923498e-20
2.81512085e-02 -1.51918780e-20]
[-7.85396329e-22 -3.01878230e-04 1.90541252e-01 ... 1.43366831e-20
2.15791427e-02 -2.21890214e-20]]]
[[[ 1.22734216e-21 1.32000940e-02 -3.15657146e-02 ... 7.85179790e-21
4.26333882e-02 4.59142561e-20]
[-1.06846966e-21 5.02914004e-02 3.03401966e-02 ... 1.59473394e-20
3.42088863e-02 1.94687200e-20]
[-8.14264599e-22 1.93091910e-02 -8.35574884e-03 ... 1.76996682e-20
3.03565413e-02 8.10803487e-21]]
[[ 1.47983106e-21 -5.18894382e-02 3.81602496e-02 ... 9.92665203e-21
5.01077957e-02 3.98922843e-20]
[-1.05100042e-21 -1.03471339e-01 -1.58639714e-01 ... 1.50322709e-20
3.99131887e-02 2.05191085e-20]
[-3.72112000e-22 -6.18229248e-03 1.29409999e-01 ... 2.04189195e-20
3.50746401e-02 1.12492040e-20]]
[[ 1.16694616e-21 1.82822235e-02 -1.19707948e-02 ... 7.18860180e-21
3.69557142e-02 2.65125814e-20]
[-1.75552162e-21 2.74308659e-02 7.39661604e-02 ... 1.28293564e-20
2.61768773e-02 -7.83802805e-22]
[-1.32682628e-21 -5.53033547e-03 -6.05111197e-02 ... 1.74154073e-20
1.93988588e-02 -4.66554301e-21]]]]
Tensor("Const_90:0", shape=(3, 3, 3, 48), dtype=float32)
The weights of the first Conv2D in MobileNet V2 CKPT:
tensor_name: MobilenetV2/Conv/weights
[[[[-8.82254463e-22 -1.10427566e-01 6.53960705e-02 ... -7.56170746e-24
1.74200931e-03 4.82577795e-22]
[-3.42111758e-22 -2.10665479e-01 -2.24913821e-01 ... 4.73884876e-22
1.42270408e-03 -6.30405280e-22]
[-3.60243240e-22 -5.61346561e-02 1.52949423e-01 ... 4.91404909e-22
1.27120805e-03 -9.90124490e-22]]
[[-9.35326400e-22 -2.63702095e-01 8.09619874e-02 ... 1.12520078e-22
1.96654163e-03 4.75749264e-22]
[-1.30903894e-22 -4.27653670e-01 -5.43912292e-01 ... 4.29817718e-22
1.57689326e-03 -6.56071911e-22]
[-2.51844084e-22 -1.34836838e-01 4.78578717e-01 ... 5.53815494e-22
1.36284437e-03 -7.92895481e-22]]
[[-8.57834662e-22 -4.96269949e-02 8.30230638e-02 ... 6.07692624e-23
1.51243573e-03 6.62790583e-23]
[ 2.77690840e-23 -9.18461531e-02 -2.37241104e-01 ... 4.68801179e-22
1.07882742e-03 -9.46952569e-22]
[-1.89589706e-22 -9.46913287e-03 1.67131335e-01 ... 5.37780237e-22
8.12531449e-04 -9.48458801e-22]]]
[[[-5.58778831e-22 -2.18475088e-02 6.85608909e-02 ... 2.66623784e-23
1.68488012e-03 1.06620663e-21]
[-5.64484764e-24 -2.52102837e-02 -2.04148248e-01 ... 2.89502587e-22
1.37694669e-03 3.98185254e-22]
[ 7.10259436e-23 -1.10837840e-03 1.48760065e-01 ... 4.81046219e-22
1.24040479e-03 -2.27577457e-23]]
[[-5.32313797e-22 -1.67327106e-01 6.50040209e-02 ... 4.50797878e-23
1.93707168e-03 9.39197851e-22]
[-2.00011991e-23 -2.63044536e-01 -5.38326025e-01 ... 4.14556023e-22
1.56085961e-03 1.06867416e-22]
[ 3.52176507e-23 -5.39213903e-02 4.86932009e-01 ... 5.42046851e-22
1.37783273e-03 -2.66949824e-22]]
[[-4.12882023e-22 -1.74710229e-02 5.53347506e-02 ... 1.48790892e-22
1.45170384e-03 3.83882183e-22]
[ 2.51626636e-22 -4.50083166e-02 -2.43759513e-01 ... 3.87876672e-22
1.05291384e-03 -3.75235839e-22]
[ 1.90810345e-22 -1.79848474e-04 2.06524894e-01 ... 4.63699710e-22
8.07259581e-04 -5.48063954e-22]]]
[[[-2.98178365e-22 1.03814108e-02 -3.63841318e-02 ... 2.53956742e-22
1.59449887e-03 1.13408017e-21]
[ 2.59582065e-22 3.66022214e-02 3.02084740e-02 ... 5.15792853e-22
1.28006085e-03 4.80873452e-22]
[ 1.97824025e-22 1.54373525e-02 -1.07837720e-02 ... 5.72471638e-22
1.13609084e-03 2.00265922e-22]]
[[-3.59520417e-22 -3.72100733e-02 3.91366594e-02 ... 3.21064899e-22
1.87432836e-03 9.85328822e-22]
[ 2.55339810e-22 -7.52819777e-02 -1.73340783e-01 ... 4.86194237e-22
1.49372115e-03 5.06817005e-22]
[ 9.04038573e-23 -3.45643470e-03 1.36962473e-01 ... 6.60427433e-22
1.31285528e-03 2.77850695e-22]]
[[-2.83509440e-22 1.34429727e-02 -1.30351204e-02 ... 2.32505632e-22
1.38183287e-03 6.54853859e-22]
[ 4.26500917e-22 1.93381794e-02 7.91313946e-02 ... 4.14948611e-22
9.79309902e-04 -1.93598457e-23]
[ 3.22350704e-22 -2.87997210e-03 -6.62560686e-02 ... 5.63280816e-22
7.25844235e-04 -1.15236788e-22]]]]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.