记录一下tf里面函数的细节变动

来源:互联网 发布:网络专科和自考专科 编辑:程序博客网 时间:2024/04/29 07:38

最近在用tensorflow写程序的时候,发现一些函数里的细小变动,导致新版本中未完全兼容旧代码,以此文记录,防止再次踩坑,长期更新……目前用的是Tensorflow gpu 1.4.0版本

图像预处理相关函数

tf.image.sample_distorted_bounding_box()

import tensorflow as tf##oldbbox_begin,bbox_size,bbox_for_draw=tf.image.sample_distorted_bounding_box(tf.shape(image),bounding_boxes=bbox)##newbbox_begin,bbox_size,bbox_for_draw=tf.image.sample_distorted_bounding_box(tf.shape(image),bounding_boxes=bbox,min_object_covered=0.1)

坑点:这里我不加显式给min_object_covered就会报ValueError: Tried to convert ‘min_object_covered’ to a tensor and failed. Error: None values not supported. 的错误。

tf.image.resize_images()

import tensorflow as tf##olddistorted_image=tf.image.resize_images(distorted_image,height,width,method=method)##newdistorted_image = tf.image.resize_images(distorted_image, size=[height, width], method=method)

坑点:这里如果不将size写为size=[height,width]的形式就会报TypeError: resize_images() got multiple values for argument ‘method’的错误。

原创粉丝点击