You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TensorFlow迁移学习:使用MobileNet替代Inception时遇NotFoundError问题

Fixing MobileNet Checkpoint NotFoundError in Transfer Learning

Hey there! I totally get how frustrating this error is— I’ve dealt with this exact checkpoint loading issue when switching models for transfer learning. Let’s break down why this is happening and how to fix it step by step:

  • Don’t specify the full checkpoint file name (only the prefix!)
    TensorFlow’s checkpoint loader expects you to use the shared prefix of the three files, not the individual .data, .index, or .meta files. For your setup, that means instead of passing mobilenet_v1_0.5_128.ckpt.data-00000-of-00001 (or any of the other two) to your restore function, you should use just mobilenet_v1_0.5_128.ckpt.

    Example of the correct code (for TF1.x):

    saver = tf.train.Saver()
    with tf.Session() as sess:
        saver.restore(sess, './path/to/mobilenet_v1_0.5_128.ckpt')  # No file extension!
    
  • Double-check your file path
    It’s easy to mix up relative vs absolute paths, or miss that your checkpoint files are nested in a subfolder.

    • Run import os; print(os.getcwd()) to confirm your current working directory.
    • Make sure the checkpoint prefix path points directly to where the three files live. If you unzipped the checkpoint into a folder named mobilenet_checkpoints, your path would be ./mobilenet_checkpoints/mobilenet_v1_0.5_128.ckpt.
  • Verify exact filename matches
    Typos happen! Check that the prefix in your code matches the actual file names perfectly— no missing characters, wrong version numbers (like 0.5 vs 05), or case mismatches (critical on Linux/Mac systems).

  • Switch to TF2.x’s built-in MobileNet API (if possible)
    If you’re using TensorFlow 2.x, you don’t need to mess with manual checkpoint loading at all. The Keras API has a pre-built MobileNet implementation that handles weights automatically:

    from tensorflow.keras.applications import MobileNetV1
    
    # Load pre-trained MobileNet with your input shape (128x128 here)
    base_model = MobileNetV1(weights='imagenet', input_shape=(128, 128, 3), include_top=False)
    # Freeze layers for transfer learning
    base_model.trainable = False
    

    This is way more reliable and avoids checkpoint path headaches entirely.

内容的提问来源于stack exchange,提问作者nassima dif

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:30:40