我从某个地方读到,如果你选择的批量大小是2,那么训练会更快.这个规则是什么?这适用于其他应用吗?你能提供参考文件吗?
我正在 MNIST 上训练自动编码器,并注意到在 128 之后增加批量大小,开始在固定数据集大小上花费更多的计算时间。
我正在使用tensorflow-gpu并拥有GeForce GTX 1070。
我尝试在 5000 个样本(784 个暗淡)的固定训练集上运行一些测试,并运行 10 个 epoch。批次是batch-size来自 5000 个训练样本的连续块,因此迭代次数实际上取决于批次大小。
我跟踪了该数据的性能(丢失)、执行时间和 python 进程的 GPU 内存使用情况(来自 nvidia-smi 输出):
5000 datapoints 10 epochs
batch size
512: loss: 53.7472; execution took 00:00:13,787; 4281MiB
256: loss: 48.1941; execution took 00:00:04,973; 695MiB
128: loss: 42.7486; execution took 00:00:03,350; 439MiB
64: loss: 40.0781; execution took 00:00:04,191; 439MiB
32: loss: 37.7348; execution took 00:00:06,487; 441MiB
16: loss: 36.6291; execution took 00:00:12,102; 441MiB
8: loss: nan; execution took 00:00:23,115; …Run Code Online (Sandbox Code Playgroud) Batch size 指的是监督学习中神经工作训练的样本数量,然而,在强化学习的背景下,batch size 的含义是什么?它也指样品吗?如果是这样,样本在强化学习背景下的意义是什么?
我正在解析一个文件并创建一个字符串元素列表,并将其插入到我的表中。我试图设置一次插入 5 行的批量大小,但不知道如何在我的代码中使用.batchupdatein 代替.update
我正在尝试在 TF2 模型中发挥作用batch_size。call()但是,我无法得到它,因为我知道的所有方法都返回None或张量而不是维度元组。
这是一个简短的例子
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.models import Model
class MyModel(Model):
def __init__(self):
super(MyModel, self).__init__()
def call(self, x):
print(len(x))
print(x.shape)
print(tf.size(x))
print(np.shape(x))
print(x.get_shape())
print(x.get_shape().as_list())
print(tf.rank(x))
print(tf.shape(x))
print(tf.shape(x)[0])
print(tf.shape(x)[1])
return tf.random.uniform((2, 10))
m = MyModel()
m.compile(optimizer="Adam", loss="sparse_categorical_crossentropy", metrics=['accuracy'])
m.fit(np.array([[1,2,3,4], [5,6,7,8]]), np.array([0, 1]), epochs=1)
Run Code Online (Sandbox Code Playgroud)
输出是:
Tensor("my_model_26/strided_slice:0", shape=(), dtype=int32)
(None, 4)
Tensor("my_model_26/Size:0", shape=(), dtype=int32)
(None, 4)
(None, 4)
[None, 4]
Tensor("my_model_26/Rank:0", shape=(), …Run Code Online (Sandbox Code Playgroud) keras tensorflow tensorflow-datasets batchsize tensorflow2.0
batchsize ×5
tensorflow ×3
gpu ×1
java ×1
jdbctemplate ×1
keras ×1
mnist ×1
spring-batch ×1
spring-boot ×1