防止混合来自不同TFRecords文件的培训示例

时间:2018-10-14 07:29:02

标签: tensorflow tfrecord

我正在训练有关视频帧序列的模型。我将视频存储为tfrecords文件(每个视频是一个单独的tfrecords文件),每个帧都编码为一个tf.train.Example。在训练期间,我读取了几批帧,并通过模型运行它们。但是,我看到来自不同视频的帧有可能以同一批结束。对于我正在训练的模型,这没有任何意义,实际上在损害性能。有没有办法确保一批帧只包含来自同一视频的帧?

1 个答案:

答案 0 :(得分:0)

我最终使用了APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}" # This script loops through the frameworks embedded in the application and # removes unused architectures. find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK do FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable) FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME" echo "Executable is $FRAMEWORK_EXECUTABLE_PATH" EXTRACTED_ARCHS=() for ARCH in $ARCHS do echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME" lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH" EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH") done echo "Merging extracted architectures: ${ARCHS}" lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}" rm "${EXTRACTED_ARCHS[@]}" echo "Replacing original executable with thinned version" rm "$FRAMEWORK_EXECUTABLE_PATH" mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH" done 方法。谓词比较第一帧和最后一帧的视频ID。如果它们不同,则将整个批次删除:

tf.data.Dataset.filter