setup_inception.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:ZOO-Attack 作者: huanzhang12 项目源码 文件源码
def predict(self, img):
    if self.use_log:
      output_name = 'InceptionV3/Predictions/Softmax:0'
    else:
      output_name = 'InceptionV3/Predictions/Reshape:0'
    # scaled = (0.5+tf.reshape(img,((299,299,3))))*255
    # scaled = (0.5+img)*255
    if img.shape.as_list()[0]:
      # check if a shape has been specified explicitly
      shape = (int(img.shape[0]), 1001)
      softmax_tensor = tf.import_graph_def(
        self.sess.graph.as_graph_def(),
        input_map={'input:0': img, 'InceptionV3/Predictions/Shape:0': shape},
        return_elements=[output_name])
    else:
      # placeholder shape
      softmax_tensor = tf.import_graph_def(
        self.sess.graph.as_graph_def(),
        input_map={'input:0': img},
        return_elements=[output_name])
    return softmax_tensor[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号