为什么生成一些TFrecord文件时不能拆分文件?

时间:2019-04-10 20:57:19

标签: python-3.x tensorflow tensorflow-datasets tfrecord

为什么在生成一些TFrecords文件时不能拆分文件?

我正在做一些预测蛋白质结构的工作。如您所知,一个蛋白质分子可能具有不同的链。因此,我需要通过链名称将原子列表分成不同的TF记录。

问题是,此代码最终生成了几条未写入任何内容的TFrecord。全部空白。

或者,在训练我的模块时,有没有一种方法可以分割线?然后,我可以忽略此问题,并将钢绞线名称作为功能添加到TFrecord中。

''' 导入了所有模块且未引发任何错误 '''


def generate_TFrecord(intPosition, endPosition, path):

    CrtS = x #x is the name of the current strand

    path = path + CrtS

    writer = tf.io.TFRecordWriter('%s.tfrecord' %path)

    for i in range(intPosition, endPosition):

        if identifyCoreCarbon(i):

            vectros  = getVectors(i)
            features = {}
            '''
            feeding this dict
            '''
            tf_features = tf.train.Features(feature = features)
            tf_example  = tf.train.Example(features = tf_features)
            tf_serialized = tf_example.SerializeToString()
            writer.write(tf_serialized)
            '''
            if checkStrand(i) == False:
                writer.write(tf_serialized)
                intPosition = i
            '''
    writer.close()
'''
strand_index is a list of all the startpoint of a single strand
'''
for loop in strand_index:
    generate_TFrecord(loop, endPosition, path)




'''
________division___________

This code below works, but only generate a single tfrecord containing all the atom imformations.


writer = tf.io.TFRecordWriter('%s.tfrecord' %path)
for i in range(0, endPosition):
    if identifyCoreCarbon(i):
        vectros  = getVectors(i)
        features = {}
        '''
        feeing features
        '''
        tf_features = tf.train.Features(feature = features)
        tf_example  = tf.train.Example(features = tf_features)
        tf_serialized = tf_example.SerializeToString()
        writer.write(tf_serialized)

writer.close()

'''

0 个答案:

没有答案