小编Sor*_*ush的帖子

TensorFlow:当批次完成培训时,tf.train.batch会自动加载下一批吗?

例如,在我创建操作后,通过操作提供批处理数据并运行操作,tf.train.batch是否自动将另一批数据输入到会话中?

我问这个是因为tf.train.batch的属性allow_smaller_final_batch使得最终批次的加载大小小于指定的批量大小.这是否意味着即使没有循环,下一批可以自动进给?从教程代码我很困惑.当我加载一个批处理时,我实际上只有一个批量大小的形状[batch_size,height,width,num_channels],但是文档说它Creates batches of tensors in tensors.也是,当我在tf-slim演练教程中阅读教程代码时,一个名为load_batch的函数,只返回了3个张量:images, images_raw, labels.如文档中所述,"批量"数据在哪里?

谢谢您的帮助.

machine-learning computer-vision deep-learning tensorflow tf-slim

17
推荐指数
1
解决办法
2万
查看次数

Keras model.predict() 在第一次迭代时变慢,然后变快

我试图model.predict()在 for 循环中多次运行并计算在同一图像上花费的时间。数据将用于计算运行预测所用时间的平均值。

如果我在单独的脚本中运行预测,它将在我的 MacBook 上运行大约 300 毫秒。如果我然后在 for 循环中迭代地运行它,所用的时间将从第一次迭代的 300 毫秒左右开始,然后在剩余的迭代中下降到 80 毫秒。

是不是因为第一个预测还留在内存中,而 Keras 在幕后做了一些事情来缩短预测时间?

知道为什么会发生这种情况吗?代码在这里:

#!/usr/bin/env python3

import argparse
import keras
from keras.applications.imagenet_utils import decode_predictions
from keras.applications.inception_v3 import preprocess_input
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppress CPU warnings
import time
from timeit import default_timer as timer
import datetime
import csv
import numpy as np

"""Define all model permutations for MobileNetsV1 and MobileNetsV2"""
# Define all V1 model permutations
# V1_MODELS = [(128,0.25)]
V1_MODELS = [(128, …
Run Code Online (Sandbox Code Playgroud)

python deep-learning keras tensorflow python-3.6

8
推荐指数
1
解决办法
3277
查看次数