相关疑难解决方法(0)

从Tensorflow中的.tfrecords文件中获取记录总数

是否有可能从.tfrecords文件中获取记录总数?与此相关,人们如何通常跟踪训练模型时已经过的时期数?虽然我们可以指定batch_sizenum_of_epochs,但我不确定是否可以直接获得诸如current epoch每个时期的批次数等值- 这样我就可以更好地控制培训的进展情况.目前,我只是使用一个肮脏的黑客来计算这个,因为我事先知道我的.tfrecords文件中有多少记录和我的miniatches的大小.感谢任何帮助..

tensorflow tfrecord

24
推荐指数
4
解决办法
1万
查看次数

在 Google Cloud Platform 中为 Keras ML 训练读取存储在桶中的数据的理想方法?

这是我第一次尝试在云中训练模型,我正在努力解决所有的小问题。我将训练数据存储在谷歌云平台内的存储桶中 gs://test/train ,数据集大约为 100k。目前,数据根据其标签分布在不同的文件夹中。

我不知道访问数据的理想方式。通常在Keras我使用,ImageDataGeneratorflow_from_directory它自动创建一个发电机,我可以喂到我的模型。

谷歌云平台是否有诸如 Python 之类的函数?

如果不是,通过生成器访问数据的理想方式是什么,以便我可以将其提供给 Keras model.fit_generator

谢谢你。

python google-cloud-platform keras tensorflow

4
推荐指数
1
解决办法
1950
查看次数

Tensorflow Keras 也使用 tfrecords 进行验证

现在我正在使用 keras 和张量流后端。数据集以 tfrecords 格式存储。没有任何验证集的训练是有效的,但如何集成我的验证tfrecords?

让我们假设这段代码是粗略的骨架:

def _ds_parser(proto):
    features = {
        'X': tf.FixedLenFeature([], tf.string),
        'Y': tf.FixedLenFeature([], tf.string)
    }

    parsed_features = tf.parse_single_example(proto, features)

    # get the data back as float32
    parsed_features['X'] = tf.decode_raw(parsed_features['I'], tf.float32)
    parsed_features['Y'] = tf.decode_raw(parsed_features['Y'], tf.float32)

    return parsed_features['X'],  parsed_features['Y']

def datasetLoader(dataSetPath, batchSize):
    dataset = tf.data.TFRecordDataset(dataSetPath)

    # Maps the parser on every filepath in the array. You can set the number of parallel loaders here
    dataset = dataset.map(_ds_parser, num_parallel_calls=8)

    # This dataset will go on forever
    dataset = dataset.repeat()

    # …
Run Code Online (Sandbox Code Playgroud)

python deep-learning keras tensorflow

4
推荐指数
1
解决办法
2055
查看次数