训练崩溃原因:保存模型时出现”tensorflow.GraphDef在序列化过程中被并发修改”

我目前正在尝试训练一个模型,我的输入管道是根据这里的答案构建的。我希望在每个epoch之后保存模型。但在训练了几个epoch后,训练就崩溃了。我了解到这是因为它将输入作为常量张量添加到图中。有人建议使用tf.placeholder来解决这个问题。不幸的是,这对我来说并没有解决问题。输入管道如下所示:

....filenames = [P_1]dataset = tf.data.TFRecordDataset(filenames)def _parse_function(example_proto):       keys_to_features = { 'data':tf.VarLenFeature(tf.float32)},       parsed_features = tf.parse_single_example(example_proto,  keys_to_features)       return tf.sparse_tensor_to_dense(parsed_features['data'])# Parse the record into tensors.dataset = dataset.map(_parse_function)# Shuffle the datasetdataset = dataset.shuffle(buffer_size=1000)# Repeat the input indefinitly dataset = dataset.repeat()      # Generate batches     dataset = dataset.batch(Batch_size) # Create a one-shot iteratoriterator = dataset.make_one_shot_iterator()data = iterator.get_next()   ....for i in range(epochs):    for ii in range(iteration):        image = sess.run(data)        ....     saver.save(sess, 'filename')

错误信息如下:

[libprotobuf FATAL external/protobuf_archive/src/google/protobuf/message_lite.cc:68] CHECK failed: (byte_size_before_serialization) == (byte_size_after_serialization): tensorflow.GraphDef was modified concurrently during serialization.terminate called after throwing an instance of 'google::protobuf::FatalException'  what():  CHECK failed: (byte_size_before_serialization) == (byte_size_after_serialization): tensorflow.GraphDef was modified concurrently during serialization.Aborted

回答:

问题似乎出在_parse_function中。请确保解析器在创建TFrecord文件时使用相同的方式。例如,确保它们具有相同的数据类型等。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注