zoukankan      html  css  js  c++  java
  • Problem after converting keras model into Tensorflow pb

    I'm using keras 2.1.* with tensorflow 1.13.* backend. I save my model during training with .h5 format and after that I convert it into protobuf (.pb) model. Everything looks good during converting process, but the result of tensorflow model is a bit weird. It shows a little bit different results. Also I'm loading keras model with not compiled mode. Something like this.

    import keras
    keras.models.load_model('model.h5', compile=False)

    Solution 1

    Most probable the problem is related to running environment. There are some variables which are being computed in training phase for future use. If you don't change to test phase, it will use current values. For example dropout and batch normalization. If you use it in training mode, then for mean and variance it will use current values, but in test time it will use moving_mean and moving_variance. That's why you should call 

    import keras.backend as K
    k.set_learning_phase(0) # 0 testing, 1 training mode

    aipool discussion: https://ai-pool.com/d/problem_after_converting_keras_model_into_tensorflow_pb

  • 相关阅读:
    [ZJOI2010] 数字计数
    [USACO] 2004 Open MooFest 奶牛集会
    数星星
    [SCOI2011] 糖果
    西瓜种植
    [NOI2018] 归程
    [APIO2012] 派遣
    小K的农场
    妮可妮可妮 [Hash]
    [ZJOI2012] 灾难
  • 原文地址:https://www.cnblogs.com/hazarapet/p/10754132.html
Copyright © 2011-2022 走看看