tensorflow python已停止工作_TensorFlow Python脚本正在被杀死

博主在学习TensorFlow时遇到问题,脚本在执行一定次数的训练操作后突然退出并显示“Killed”。问题可能出现在添加摘要写作器操作后,怀疑存在内存泄漏。代码包括数据加载、图像增强、LeNet模型定义、训练和评估过程。博主已确认部分代码无误,但无法定位问题所在,寻求解决方案。
摘要由CSDN通过智能技术生成

我是张量流的初学者。我的TensorFlow脚本突然退出,说Killed。我的代码如下:import tensorflow as tf

# Load data X_train, y_train and X_valid, y_valid

# An image augmentation pipeline

def augment(x):

x = tf.image.random_brightness(x, max_delta=0.2)

x = tf.image.random_contrast(x, 0.5, 2)

return x

from sklearn.utils import shuffle

X_train, y_train = shuffle(X_train, y_train)

def LeNet(x):

# Define LeNet architecture

return logits

# Features:

x = tf.placeholder(tf.float32, (None, 32, 32, 3))

# Labels:

y = tf.placeholder(tf.int32, (None))

# Dropout probability

prob = tf.placeholder(tf.float32, (None))

# Learning rate

rate = tf.placeholder(tf.float32, (None))

rate_summary = tf.summary.scalar('learning rate', rate)

logits = LeNet(x)

accuracy_operation = # defined accuracy_operation

accuracy_summary = tf.summary.scalar('validation accuracy', accuracy_operation)

saver = tf.train.Saver()

summary = tf.summary.merge_all()

writer = tf.summary.FileWriter('./summary', tf.get_default_graph())

def evaluate(X_data, y_data):

# Return accuracy with X_data, y_data

return accuracy

with tf.Session() as sess:

saver.restore(sess, './lenet')

for i in range(EPOCHS):

X_train, y_train = shuffle(X_train, y_train)

for offset in range(0, len(X_train), BATCH_SIZE):

end = offset + BATCH_SIZE

batch_x, batch_y = X_train[offset:end], y_train[offset:end]

batch_x = sess.run(augment(batch_x))

# Run the training operation, update learning rate

validation_accuracy = evaluate(X_valid, y_valid)

writer.add_summary(sess.run(summary, feed_dict = {x: X_valid, y: y_valid, prob: 1., rate: alpha}))

我省略了我知道肯定不会引起问题的部分。我知道哪些部分是好的,因为剧本之前没有给任何麻烦。在添加某些部分(主要是摘要编写器操作)之后,脚本会突然说Killed,并在执行一定数量的训练操作后退出。我怀疑这是由于内存泄漏,但我无法检测到。在

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值