tensorflow越跑越慢_每次迭代后处理时间越来越长(TensorFlow)

我正在训练一个CNN与TensorFlow医学图像应用。在

由于我没有太多的数据,我试图在训练循环期间对训练批应用随机修改,以人为地增加训练数据集。我用不同的脚本编写了以下函数,并在我的培训批处理中调用它:def randomly_modify_training_batch(images_train_batch, batch_size):

for i in range(batch_size):

image = images_train_batch[i]

image_tensor = tf.convert_to_tensor(image)

distorted_image = tf.image.random_flip_left_right(image_tensor)

distorted_image = tf.image.random_flip_up_down(distorted_image)

distorted_image = tf.image.random_brightness(distorted_image, max_delta=60)

distorted_image = tf.image.random_contrast(distorted_image, lower=0.2, upper=1.8)

with tf.Session():

images_train_batch[i] = distorted_image.eval() # .eval() is used to reconvert the image from Tensor type to ndarray

return images_train_batch

代码很好地应用到我的图像修改。在

问题是:

在我的下一次训练中,每一次训练的循环时间都比我训练的每一次循环长5秒。在

它需要大约1秒的时间来处理,经过10次以上的迭代,处理时间超过一分钟。在

是什么导致了这种放缓?

我怎样才能防止呢?在

(我怀疑是distorted_image.eval()的东西,但我不太确定。我每次都开一个新的会议?TensorFlow不应该像我在“with”中使用的那样自动关闭会话tf.会议()“阻止?)在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值