1、fit_generator()的测试集的val_acc 怎么实现,当目标值使用one-hot编码,是完全正确算一次正确?能否批量测试?经过调试程序跟踪发现:程序通过调用model.evaluate()实现,默认的测试batch_size使用训练集的batch_size,当训练集batch_size为1时,batch_ous返回损失值和acc,其中acc为0,或者1,当训练集batch_size=2,返回0,0.5,1,所以为分类正确返回0,1进行统计得来,不是浮点数统计,并且可以批量测试,每批次大小就是训练集每步大小。另外发现:tf1.8自带keras默认为非eager模式,使用传统模式。
test_loop()源码相关节选如下:
batch_outs = f(ins_batch)
if isinstance(batch_outs, list):
if batch_index == 0:
for batch_out in enumerate(batch_outs):
outs.append(0.)
for i, batch_out in enumerate(batch_outs):
if i in stateful_metric_indices:
outs[i] = batch_out
else:
outs[i] += batch_out * len(batch_ids) #统计
else:
if batch_index == 0:
outs.append(0.)
outs[0] += batch_outs * len(batch_ids)
if verbose == 1:
progbar.update(batch_end)
for i in range(len(outs)):
if i not in stateful_metric_indices:
outs[i] /= num_samples #取均值
if len(outs) == 1:
return outs[0]
return outs
2、单只股票训练结果优于多只股票一起训练,batch_size没意义。
3、非归一化结果不理想,改为归一化处理,数值归一化,周期非0归一化。