【问题标题】:Transferlearning with tensorflow hub inception v1 doesn't predict well使用 tensorflow hub inception v1 进行迁移学习并不能很好地预测
【发布时间】:2021-07-03 15:57:00
【问题描述】:

我正在尝试使用 inceptionv1 进行迁移学习,但分类器无法很好地预测一张图像,这是怎么回事?

    from skimage.transform import resize
    m = tf.keras.Sequential([hub.KerasLayer("https://tfhub.dev/google/imagenet/inception_v1/classification/4")])     # load the tensorflow hub model
    m.build([None, 224, 224, 3])
    rimg = resize(img, output_shape=(1,224,224,3),anti_aliasing=True)   # resize and reshape the image to [1,224,224,3] 
    rimg = (rimg-np.min(rimg))/(np.max(rimg)-np.min(rimg)).astype(np.float32)  # normalize the image to a [0,1] range
    logits = m(rimg) # feed the image into the model to obtain the logits 
    probs  = np.exp(logits)/(np.sum(np.exp(logits))) # convert logits to probabilities

【问题讨论】:

    标签: tensorflow deep-learning conv-neural-network tensorflow-hub


    【解决方案1】:

    您正在应用最小-最大归一化,同时应使用将每个像素值除以 255。具体来说,可能的最小强度像素值 (0) 应该映射到 0,而最大值 (255) 应该映射到 1。因此,像 [64, 128] 这样的图像应该映射到 [0.25, 0.5],而您的归一化将其映射到 @改为 987654323@。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-06
      • 1970-01-01
      • 2016-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-12
      • 2017-11-23
      相关资源
      最近更新 更多