微信公众号:小白图像与视觉
关于技术、关注
yysilence00
。有问题或建议,请公众号留言。
✓代码跑通
请大家根据课上所学内容,在 VGGNet类中补全代码,构造VGG网络,保证程序跑通。在VGG构造成功的基础上,可尝试构造其他网络。
✓调优
思考并动手进行调优,以在验证集上的准确率为评价指标,验证集上准确率越高,得分越高!
任务描述:
口罩识别,是指可以有效检测在密集人流区域中携带和未携戴口罩的所有人脸,同时判断该者是否佩戴口罩。通常由两个功能单元组成,可以分别完成口罩人脸的检测和口罩人脸的分类。
本次实践相比生产环境中口罩识别的问题,降低了难度,仅实现人脸口罩判断模型,可实现对人脸是否佩戴口罩的判定。本实践旨在通过一个口罩识别的案列,让大家理解和掌握如何使用飞桨动态图搭建一个经典的卷积神经网络
特别提示:本实践所用数据集均来自互联网,请勿用于商务用途。
import os
import zipfile
import random
import json
import paddle
import sys
import numpy as np
from PIL import Image
from PIL import ImageEnhance
import paddle.fluid as fluid
from multiprocessing import cpu_count
import matplotlib.pyplot as plt
'''
参数配置
'''
train_parameters = {
"input_size": [3, 224, 224], #输入图片的shape
"class_dim": -1, #分类数
"src_path":"/home/aistudio/work/maskDetect.zip",#原始数据集路径
"target_path":"/home/aistudio/data/", #要解压的路径
"train_list_path": "/home/aistudio/data/train.txt", #train.txt路径
"eval_list_path": "/home/aistudio/data/eval.txt", #eval.txt路径
"readme_path": "/home/aistudio/data/readme.json", #readme.json路径
"label_dict":{}, #标签字典
"num_epochs": 30, #训练轮数
"train_batch_size": 8, #训练时每个批次的大小
"learning_strategy": { #优化函数相关的配置
"lr": 0.001 #超参数学习率
}
}
(1)解压原始数据集
(2)按照比例划分训练集与验证集
(3)乱序,生成数据列表
(4)构造训练数据集提供器和验证数据集提供器
def unzip_data(src_path,target_path):
'''
解压原始数据集,将src_path路径下的zip包解压至data目录下
'''
if(not os.path.isdir(target_path + "maskDetect")):
z = zipfile.ZipFile(src_path, 'r')
z.extractall(path=target_path)
z.close()
def get_data_list(target_path,train_list_path,eval_list_path):
'''
生成数据列表
'''
#存放所有类别的信息
class_detail = []
#获取所有类别保存的文件夹名称
data_list_path=target_path+"maskDetect/"
class_dirs = os.listdir(data_list_path)
#总的图像数量
all_class_images = 0
#存放类别标签
class_label=0
#存放类别数目
class_dim = 0
#存储要写进eval.txt和train.txt中的内容
trainer_list=[]
eval_list=[]
#读取每个类别,['maskimages', 'nomaskimages']
for class_dir in class_dirs:
if class_dir != ".DS_Store":
class_dim += 1
#每个类别的信息
class_detail_list = {}
eval_sum = 0
trainer_sum = 0
#统计每个类别有多少张图片
class_sum = 0
#获取类别路径
path = data_list_path + class_dir
# 获取所有图片
img_paths = os.listdir(path)
for img_path in img_paths: # 遍历文件夹下的每个图片
name_path = path + '/' + img_path # 每张图片的路径
if class_sum % 10 == 0: # 每10张图片取一个做验证数据
eval_sum += 1 # test_sum为测试数据的数目
eval_list.append(name_path + "\t%d" % class_label + "\n")
else:
trainer_sum += 1
trainer_list.append(name_path + "\t%d" % class_label + "\n")#trainer_sum测试数据的数目
class_sum += 1 #每类图片的数目
all_class_images += 1 #所有类图片的数目
# 说明的json文件的class_detail数据
class_detail_list['class_name'] = class_dir #类别名称,如jiangwen
class_detail_list['class_label'] = class_label #类别标签
class_detail_list['class_eval_images'] = eval_sum #该类数据的测试集数目
class_detail_list['class_trainer_images'] = trainer_sum #该类数据的训练集数目
class_detail.append(class_detail_list)
#初始化标签列表
train_parameters['label_dict'][str(class_label)] = class_dir
class_label += 1
#初始化分类数
train_parameters['class_dim'] = class_dim
#乱序
random.shuffle(eval_list)
with open(eval_list_path, 'a') as f:
for eval_image in eval_list:
f.write(eval_image)
random.shuffle(trainer_list)
with open(train_list_path, 'a') as f2:
for train_image in trainer_list:
f2.write(train_image)
# 说明的json文件信息
readjson = {}
readjson['all_class_name'] = data_list_path #文件父目录
readjson['all_class_images'] = all_class_images
readjson['class_detail'] = class_detail
jsons = json.dumps(readjson, sort_keys=True, indent=4, separators=(',', ': '))
with open(train_parameters['readme_path'],'w') as f:
f.write(jsons)
print ('生成数据列表完成!')
def custom_reader(file_list):
'''
自定义reader
'''
def reader():
with open(file_list, 'r') as f:
lines = [line.strip() for line in f]
for line in lines:
img_path, lab = line.strip().split('\t')
img = Image.open(img_path)
if img.mode != 'RGB':
img = img.convert('RGB')
img = img.resize((224, 224), Image.BILINEAR)
img = np.array(img).astype('float32')
img = img.transpose((2, 0, 1)) # HWC to CHW
img = img/255 # 像素值归一化
yield img, int(lab)
return reader
'''
参数初始化
'''
src_path=train_parameters['src_path']
target_path=train_parameters['target_path']
train_list_path=train_parameters['train_list_path']
eval_list_path=train_parameters['eval_list_path']
batch_size=train_parameters['train_batch_size']
'''
解压原始数据到指定路径
'''
unzip_data(src_path,target_path)
'''
划分训练集与验证集,乱序,生成数据列表
'''
#每次生成数据列表前,首先清空train.txt和eval.txt
with open(train_list_path, 'w') as f:
f.seek(0)
f.truncate()
with open(eval_list_path, 'w') as f:
f.seek(0)
f.truncate()
#生成数据列表
get_data_list(target_path,train_list_path,eval_list_path)
'''
构造数据提供器
'''
train_reader = paddle.batch(custom_reader(train_list_path),
batch_size=batch_size,
drop_last=True)
eval_reader = paddle.batch(custom_reader(eval_list_path),
batch_size=batch_size,
drop_last=True)
生成数据列表完成!
VGG的核心是五组卷积操作,每两组之间做Max-Pooling空间降维。同一组内采用多次连续的3X3卷积,卷积核的数目由较浅组的64增多到最深组的512,同一组内的卷积核数目是一样的。卷积之后接两层全连接层,之后是分类层。由于每组内卷积层的不同,有11、13、16、19层这几种模型,上图展示一个16层的网络结构。
class ConvPool(fluid.dygraph.Layer):
'''卷积+池化'''
def __init__(self,
num_channels,
num_filters,
filter_size,
pool_size,
pool_stride,
groups,
pool_padding=0,
pool_type='max',
conv_stride=1,
conv_padding=1,
act=None):
super(ConvPool, self).__init__()
self._conv2d_list = []
for i in range(groups):
conv2d = self.add_sublayer( #返回一个由所有子层组成的列表。
'bb_%d' % i,
fluid.dygraph.Conv2D(
num_channels=num_channels, #通道数
num_filters=num_filters, #卷积核个数
filter_size=filter_size, #卷积核大小
stride=conv_stride, #步长
padding=conv_padding, #padding大小,默认为0
act=act)
)
num_channels = num_filters
self._conv2d_list.append(conv2d)
self._pool2d = fluid.dygraph.Pool2D(
pool_size=pool_size, #池化核大小
pool_type=pool_type, #池化类型,默认是最大池化
pool_stride=pool_stride, #池化步长
pool_padding=pool_padding #填充大小
)
def forward(self, inputs):
x = inputs
for conv in self._conv2d_list:
x = conv(x)
x = self._pool2d(x)
return x
class VGGNet(fluid.dygraph.Layer):
'''
VGG网络
'''
def __init__(self):
super(VGGNet, self).__init__()
self.convpool01 = ConvPool(3, 64, 3, 2, 2, 2, act="relu") #3:通道, 64:卷积核个数, 3:卷积核大小 2:池化核大小, 2:池化步长 2:连续卷积个数
self.convpool02 = ConvPool( 64, 128, 3, 2 , 2, 2, act="relu")
self.convpool03 = ConvPool(128, 256, 3, 2 , 2, 3, act="relu")
self.convpool04 = ConvPool(256, 512, 3, 2 , 2, 3, act="relu")
self.convpool05 = ConvPool(512, 512, 3, 2 , 2, 3, act="relu")
self.pool_5_shape = 512 * 7 * 7
self.fc01 = fluid.dygraph.Linear(self.pool_5_shape, 4096, act = "relu")
self.fc02 = fluid.dygraph.Linear(4096, 4096, act = "relu")
self.fc03 = fluid.dygraph.Linear(4096, 2, act = "softmax")
def forward(self, inputs, label=None):
"""前向计算"""
#print(inputs.shape) #[8, 3 , 224, 224]
out = self.convpool01(inputs)
##print(out.shape) #[8, 64 , 112, 112]
out = self.convpool02(out)
##print(out.shape) #[8, 128 , 56, 56]
out = self.convpool03(out)
##print(out.shape) #[8, 256 , 28, 28]
out = self.convpool04(out)
##print(out.shape) #[8, 512 , 14, 14]
out = self.convpool05(out)
#print(out.shape) #[8, 512 , 7, 7]
out = fluid.layers.reshape(out, shape=[-1, 512 * 7 * 7])
out = self.fc01(out)
out = self.fc02(out)
out = self.fc03(out)
if label is not None:
acc = fluid.layers.accuracy(input=out, label=label)
return out, acc
else:
return out
all_train_iter=0
all_train_iters=[]
all_train_costs=[]
all_train_accs=[]
def draw_train_process(title,iters,costs,accs,label_cost,lable_acc):
plt.title(title, fontsize=24)
plt.xlabel("iter", fontsize=20)
plt.ylabel("cost/acc", fontsize=20)
plt.plot(iters, costs,color='red',label=label_cost)
plt.plot(iters, accs,color='green',label=lable_acc)
plt.legend()
plt.grid()
plt.show()
def draw_process(title,color,iters,data,label):
plt.title(title, fontsize=24)
plt.xlabel("iter", fontsize=20)
plt.ylabel(label, fontsize=20)
plt.plot(iters, data,color=color,label=label)
plt.legend()
plt.grid()
plt.show()
'''
模型训练
'''
with fluid.dygraph.guard(place = fluid.CUDAPlace(0)):
#with fluid.dygraph.guard():
print(train_parameters['class_dim'])
print(train_parameters['label_dict'])
vgg = VGGNet()
optimizer=fluid.optimizer.AdamOptimizer(learning_rate=train_parameters['learning_strategy']['lr'],parameter_list=vgg.parameters())
for epoch_num in range(train_parameters['num_epochs']):
for batch_id, data in enumerate(train_reader()):
dy_x_data = np.array([x[0] for x in data]).astype('float32')
y_data = np.array([x[1] for x in data]).astype('int64')
y_data = y_data[:, np.newaxis]
#将Numpy转换为DyGraph接收的输入
img = fluid.dygraph.to_variable(dy_x_data)
label = fluid.dygraph.to_variable(y_data)
out,acc = vgg(img,label)
loss = fluid.layers.cross_entropy(out, label)
avg_loss = fluid.layers.mean(loss)
#使用backward()方法可以执行反向网络
avg_loss.backward()
optimizer.minimize(avg_loss)
#将参数梯度清零以保证下一轮训练的正确性
vgg.clear_gradients()
all_train_iter=all_train_iter+train_parameters['train_batch_size']
all_train_iters.append(all_train_iter)
all_train_costs.append(loss.numpy()[0])
all_train_accs.append(acc.numpy()[0])
if batch_id % 1 == 0:
print("Loss at epoch {} step {}: {}, acc: {}".format(epoch_num, batch_id, avg_loss.numpy(), acc.numpy()))
draw_train_process("training",all_train_iters,all_train_costs,all_train_accs,"trainning cost","trainning acc")
draw_process("trainning loss","red",all_train_iters,all_train_costs,"trainning loss")
draw_process("trainning acc","green",all_train_iters,all_train_accs,"trainning acc")
#保存模型参数
fluid.save_dygraph(vgg.state_dict(), "vgg")
print("Final loss: {}".format(avg_loss.numpy()))
2
{'0': 'maskimages', '1': 'nomaskimages'}
Loss at epoch 0 step 0: [0.7757668], acc: [0.375]
Loss at epoch 0 step 1: [2.9185987], acc: [0.75]
Loss at epoch 0 step 2: [48.], acc: [0.25]
Loss at epoch 0 step 3: [32.], acc: [0.5]
Loss at epoch 0 step 4: [2.3350415], acc: [0.875]
Loss at epoch 0 step 5: [3.3371205], acc: [0.5]
Loss at epoch 0 step 6: [3.545965], acc: [0.25]
Loss at epoch 0 step 7: [2.1367373], acc: [0.375]
Loss at epoch 0 step 8: [1.2625244], acc: [0.5]
Loss at epoch 0 step 9: [0.73507476], acc: [0.125]
Loss at epoch 0 step 10: [0.8343065], acc: [0.375]
Loss at epoch 0 step 11: [0.6979168], acc: [0.5]
Loss at epoch 0 step 12: [0.7317828], acc: [0.375]
Loss at epoch 0 step 13: [0.458363], acc: [0.75]
Loss at epoch 0 step 14: [1.2603776], acc: [0.5]
Loss at epoch 0 step 15: [0.30895427], acc: [0.875]
Loss at epoch 0 step 16: [0.4887264], acc: [0.75]
Loss at epoch 0 step 17: [0.6346784], acc: [0.625]
Loss at epoch 0 step 18: [0.7971215], acc: [0.375]
Loss at epoch 0 step 19: [0.7731848], acc: [0.25]
Loss at epoch 1 step 0: [0.68158674], acc: [0.75]
Loss at epoch 1 step 1: [0.5907934], acc: [0.875]
Loss at epoch 1 step 2: [0.5610034], acc: [0.75]
Loss at epoch 1 step 3: [1.0862074], acc: [0.5]
Loss at epoch 1 step 4: [0.34016088], acc: [0.875]
Loss at epoch 1 step 5: [0.68631446], acc: [0.5]
Loss at epoch 1 step 6: [0.5536125], acc: [0.75]
Loss at epoch 1 step 7: [0.68393826], acc: [0.375]
Loss at epoch 1 step 8: [0.62486637], acc: [0.5]
Loss at epoch 1 step 9: [0.5470375], acc: [0.875]
Loss at epoch 1 step 10: [0.67743564], acc: [0.375]
Loss at epoch 1 step 11: [0.58173585], acc: [0.625]
Loss at epoch 1 step 12: [0.5367519], acc: [0.625]
Loss at epoch 1 step 13: [0.38561583], acc: [1.]
Loss at epoch 1 step 14: [0.82316864], acc: [0.5]
Loss at epoch 1 step 15: [0.26491898], acc: [1.]
Loss at epoch 1 step 16: [0.33855426], acc: [0.875]
Loss at epoch 1 step 17: [0.46126628], acc: [0.875]
Loss at epoch 1 step 18: [0.56190467], acc: [0.625]
Loss at epoch 1 step 19: [0.9134719], acc: [0.25]
Loss at epoch 2 step 0: [0.6907586], acc: [0.75]
Loss at epoch 2 step 1: [0.27605337], acc: [1.]
Loss at epoch 2 step 2: [0.4249292], acc: [0.75]
Loss at epoch 2 step 3: [1.0457458], acc: [0.5]
Loss at epoch 2 step 4: [0.39506966], acc: [1.]
Loss at epoch 2 step 5: [0.65192086], acc: [0.625]
Loss at epoch 2 step 6: [0.52468705], acc: [0.875]
Loss at epoch 2 step 7: [0.3963334], acc: [0.75]
Loss at epoch 2 step 8: [0.44273317], acc: [0.75]
Loss at epoch 2 step 9: [0.3142467], acc: [0.875]
Loss at epoch 2 step 10: [0.59408635], acc: [0.5]
Loss at epoch 2 step 11: [0.31137615], acc: [1.]
Loss at epoch 2 step 12: [0.31012034], acc: [0.875]
Loss at epoch 2 step 13: [0.30957353], acc: [1.]
Loss at epoch 2 step 14: [0.53263134], acc: [0.625]
Loss at epoch 2 step 15: [0.22359051], acc: [1.]
Loss at epoch 2 step 16: [0.06968997], acc: [1.]
Loss at epoch 2 step 17: [0.18589865], acc: [0.875]
Loss at epoch 2 step 18: [0.09896165], acc: [1.]
Loss at epoch 2 step 19: [1.050614], acc: [0.625]
Loss at epoch 3 step 0: [2.6778648], acc: [0.625]
Loss at epoch 3 step 1: [0.05035767], acc: [1.]
Loss at epoch 3 step 2: [0.4414662], acc: [0.75]
Loss at epoch 3 step 3: [0.71154404], acc: [0.625]
Loss at epoch 3 step 4: [0.29253334], acc: [0.875]
Loss at epoch 3 step 5: [0.58789563], acc: [0.625]
Loss at epoch 3 step 6: [0.8520256], acc: [0.25]
Loss at epoch 3 step 7: [0.4283576], acc: [0.875]
Loss at epoch 3 step 8: [0.40886497], acc: [0.875]
Loss at epoch 3 step 9: [0.29544568], acc: [1.]
Loss at epoch 3 step 10: [0.92552286], acc: [0.5]
Loss at epoch 3 step 11: [0.19973832], acc: [1.]
Loss at epoch 3 step 12: [0.47745904], acc: [0.75]
Loss at epoch 3 step 13: [0.83689106], acc: [0.5]
Loss at epoch 3 step 14: [0.1486199], acc: [1.]
Loss at epoch 3 step 15: [0.06511814], acc: [1.]
Loss at epoch 3 step 16: [0.4327502], acc: [0.875]
Loss at epoch 3 step 17: [0.7492923], acc: [0.75]
Loss at epoch 3 step 18: [0.20050848], acc: [0.875]
Loss at epoch 3 step 19: [0.85543954], acc: [0.5]
Loss at epoch 4 step 0: [0.26853618], acc: [1.]
Loss at epoch 4 step 1: [0.42150497], acc: [0.75]
Loss at epoch 4 step 2: [0.70920265], acc: [0.75]
Loss at epoch 4 step 3: [0.3501124], acc: [0.75]
Loss at epoch 4 step 4: [0.19546595], acc: [0.875]
Loss at epoch 4 step 5: [0.25054154], acc: [1.]
Loss at epoch 4 step 6: [0.10764527], acc: [1.]
Loss at epoch 4 step 7: [0.16239104], acc: [1.]
Loss at epoch 4 step 8: [0.11918306], acc: [1.]
Loss at epoch 4 step 9: [0.18955322], acc: [0.875]
Loss at epoch 4 step 10: [0.14804724], acc: [1.]
Loss at epoch 4 step 11: [0.06330815], acc: [1.]
Loss at epoch 4 step 12: [0.09190951], acc: [1.]
Loss at epoch 4 step 13: [0.01365341], acc: [1.]
Loss at epoch 4 step 14: [0.03031916], acc: [1.]
Loss at epoch 4 step 15: [0.11752094], acc: [1.]
Loss at epoch 4 step 16: [0.00377297], acc: [1.]
Loss at epoch 4 step 17: [0.32305968], acc: [0.875]
Loss at epoch 4 step 18: [0.53758854], acc: [0.875]
Loss at epoch 4 step 19: [0.14154533], acc: [1.]
Loss at epoch 5 step 0: [1.4260217], acc: [0.75]
Loss at epoch 5 step 1: [0.6332914], acc: [0.625]
Loss at epoch 5 step 2: [0.3709383], acc: [0.875]
Loss at epoch 5 step 3: [0.24413773], acc: [0.875]
Loss at epoch 5 step 4: [0.19937845], acc: [0.875]
Loss at epoch 5 step 5: [0.31788236], acc: [1.]
Loss at epoch 5 step 6: [0.12586379], acc: [1.]
Loss at epoch 5 step 7: [0.27669448], acc: [0.875]
Loss at epoch 5 step 8: [0.20768316], acc: [1.]
Loss at epoch 5 step 9: [0.18495092], acc: [0.875]
Loss at epoch 5 step 10: [0.21615139], acc: [0.875]
Loss at epoch 5 step 11: [0.35578933], acc: [0.875]
Loss at epoch 5 step 12: [0.11185273], acc: [1.]
Loss at epoch 5 step 13: [0.07672081], acc: [1.]
Loss at epoch 5 step 14: [0.23202385], acc: [0.875]
Loss at epoch 5 step 15: [0.8284117], acc: [0.625]
Loss at epoch 5 step 16: [0.09256542], acc: [1.]
Loss at epoch 5 step 17: [0.9655455], acc: [0.875]
Loss at epoch 5 step 18: [1.4219186], acc: [0.625]
Loss at epoch 5 step 19: [0.11835418], acc: [1.]
Loss at epoch 6 step 0: [0.3255823], acc: [0.75]
Loss at epoch 6 step 1: [0.33641487], acc: [0.75]
Loss at epoch 6 step 2: [0.44094205], acc: [0.875]
Loss at epoch 6 step 3: [0.30993578], acc: [0.875]
Loss at epoch 6 step 4: [0.5291194], acc: [0.75]
Loss at epoch 6 step 5: [0.6381337], acc: [0.5]
Loss at epoch 6 step 6: [0.36480778], acc: [0.875]
Loss at epoch 6 step 7: [1.2966185], acc: [0.5]
Loss at epoch 6 step 8: [0.6657913], acc: [0.5]
Loss at epoch 6 step 9: [0.13745005], acc: [1.]
Loss at epoch 6 step 10: [0.12371652], acc: [1.]
Loss at epoch 6 step 11: [0.12100139], acc: [1.]
Loss at epoch 6 step 12: [0.28778672], acc: [0.875]
Loss at epoch 6 step 13: [0.10272555], acc: [1.]
Loss at epoch 6 step 14: [1.0915629], acc: [0.625]
Loss at epoch 6 step 15: [0.15152624], acc: [0.875]
Loss at epoch 6 step 16: [0.02559968], acc: [1.]
Loss at epoch 6 step 17: [0.2904293], acc: [0.875]
Loss at epoch 6 step 18: [0.05349303], acc: [1.]
Loss at epoch 6 step 19: [0.08815353], acc: [1.]
Loss at epoch 7 step 0: [0.7132384], acc: [0.75]
Loss at epoch 7 step 1: [0.05057724], acc: [1.]
Loss at epoch 7 step 2: [0.3724563], acc: [0.875]
Loss at epoch 7 step 3: [0.10281967], acc: [1.]
Loss at epoch 7 step 4: [0.24077807], acc: [0.875]
Loss at epoch 7 step 5: [0.614025], acc: [0.5]
Loss at epoch 7 step 6: [0.18448691], acc: [1.]
Loss at epoch 7 step 7: [0.28377116], acc: [0.875]
Loss at epoch 7 step 8: [0.08368813], acc: [1.]
Loss at epoch 7 step 9: [0.17365932], acc: [0.875]
Loss at epoch 7 step 10: [0.12609705], acc: [1.]
Loss at epoch 7 step 11: [0.04215823], acc: [1.]
Loss at epoch 7 step 12: [0.12285078], acc: [1.]
Loss at epoch 7 step 13: [0.03972214], acc: [1.]
Loss at epoch 7 step 14: [0.33206728], acc: [0.75]
Loss at epoch 7 step 15: [0.01143005], acc: [1.]
Loss at epoch 7 step 16: [0.01025122], acc: [1.]
Loss at epoch 7 step 17: [0.08599798], acc: [1.]
Loss at epoch 7 step 18: [0.06229644], acc: [1.]
Loss at epoch 7 step 19: [0.02149708], acc: [1.]
Loss at epoch 8 step 0: [0.41639307], acc: [0.875]
Loss at epoch 8 step 1: [0.37782842], acc: [0.75]
Loss at epoch 8 step 2: [0.7373229], acc: [0.875]
Loss at epoch 8 step 3: [0.09006456], acc: [1.]
Loss at epoch 8 step 4: [0.15535733], acc: [0.875]
Loss at epoch 8 step 5: [0.10121983], acc: [1.]
Loss at epoch 8 step 6: [0.02529579], acc: [1.]
Loss at epoch 8 step 7: [0.08361211], acc: [1.]
Loss at epoch 8 step 8: [0.33710602], acc: [0.875]
Loss at epoch 8 step 9: [0.03603335], acc: [1.]
Loss at epoch 8 step 10: [0.01322603], acc: [1.]
Loss at epoch 8 step 11: [0.02558591], acc: [1.]
Loss at epoch 8 step 12: [0.03191826], acc: [1.]
Loss at epoch 8 step 13: [0.3902778], acc: [0.875]
Loss at epoch 8 step 14: [0.01148503], acc: [1.]
Loss at epoch 8 step 15: [0.0036118], acc: [1.]
Loss at epoch 8 step 16: [0.00775307], acc: [1.]
Loss at epoch 8 step 17: [0.16436253], acc: [0.875]
Loss at epoch 8 step 18: [0.61385113], acc: [0.875]
Loss at epoch 8 step 19: [0.01663564], acc: [1.]
Loss at epoch 9 step 0: [0.70729065], acc: [0.75]
Loss at epoch 9 step 1: [0.04276252], acc: [1.]
Loss at epoch 9 step 2: [0.6690418], acc: [0.75]
Loss at epoch 9 step 3: [0.4211917], acc: [0.875]
Loss at epoch 9 step 4: [0.34694785], acc: [0.875]
Loss at epoch 9 step 5: [0.36310077], acc: [0.75]
Loss at epoch 9 step 6: [0.21403885], acc: [0.875]
Loss at epoch 9 step 7: [0.25339147], acc: [0.875]
Loss at epoch 9 step 8: [0.02999027], acc: [1.]
Loss at epoch 9 step 9: [0.07734257], acc: [1.]
Loss at epoch 9 step 10: [0.10303803], acc: [1.]
Loss at epoch 9 step 11: [0.56203777], acc: [0.75]
Loss at epoch 9 step 12: [0.05176272], acc: [1.]
Loss at epoch 9 step 13: [0.00882518], acc: [1.]
Loss at epoch 9 step 14: [0.09075432], acc: [1.]
Loss at epoch 9 step 15: [0.0096813], acc: [1.]
Loss at epoch 9 step 16: [0.00372064], acc: [1.]
Loss at epoch 9 step 17: [0.03116843], acc: [1.]
Loss at epoch 9 step 18: [0.01668372], acc: [1.]
Loss at epoch 9 step 19: [0.00782026], acc: [1.]
Loss at epoch 10 step 0: [0.03001343], acc: [1.]
Loss at epoch 10 step 1: [1.5971364], acc: [0.625]
Loss at epoch 10 step 2: [0.5381085], acc: [0.875]
Loss at epoch 10 step 3: [10.306136], acc: [0.5]
Loss at epoch 10 step 4: [0.620942], acc: [0.875]
Loss at epoch 10 step 5: [0.08098315], acc: [1.]
Loss at epoch 10 step 6: [0.12605943], acc: [1.]
Loss at epoch 10 step 7: [0.2696467], acc: [0.875]
Loss at epoch 10 step 8: [0.24541776], acc: [1.]
Loss at epoch 10 step 9: [0.81628627], acc: [0.75]
Loss at epoch 10 step 10: [0.26025838], acc: [0.875]
Loss at epoch 10 step 11: [0.2501353], acc: [1.]
Loss at epoch 10 step 12: [0.45576543], acc: [1.]
Loss at epoch 10 step 13: [0.36464214], acc: [0.875]
Loss at epoch 10 step 14: [0.21221855], acc: [1.]
Loss at epoch 10 step 15: [0.20198119], acc: [1.]
Loss at epoch 10 step 16: [0.12827264], acc: [0.875]
Loss at epoch 10 step 17: [0.29254037], acc: [0.875]
Loss at epoch 10 step 18: [0.46395522], acc: [0.625]
Loss at epoch 10 step 19: [0.41962242], acc: [0.75]
Loss at epoch 11 step 0: [1.0264462], acc: [0.625]
Loss at epoch 11 step 1: [0.02121847], acc: [1.]
Loss at epoch 11 step 2: [0.21737432], acc: [0.875]
Loss at epoch 11 step 3: [0.2753225], acc: [0.875]
Loss at epoch 11 step 4: [0.20556769], acc: [0.875]
Loss at epoch 11 step 5: [0.5707569], acc: [0.75]
Loss at epoch 11 step 6: [0.2887736], acc: [0.875]
Loss at epoch 11 step 7: [0.26266706], acc: [0.875]
Loss at epoch 11 step 8: [0.31126493], acc: [0.875]
Loss at epoch 11 step 9: [0.315235], acc: [0.875]
Loss at epoch 11 step 10: [0.22998768], acc: [1.]
Loss at epoch 11 step 11: [0.08676386], acc: [1.]
Loss at epoch 11 step 12: [0.1459551], acc: [1.]
Loss at epoch 11 step 13: [0.12891516], acc: [1.]
Loss at epoch 11 step 14: [0.15577655], acc: [1.]
Loss at epoch 11 step 15: [0.0763185], acc: [1.]
Loss at epoch 11 step 16: [0.01633451], acc: [1.]
Loss at epoch 11 step 17: [0.32553416], acc: [0.875]
Loss at epoch 11 step 18: [0.43950263], acc: [0.75]
Loss at epoch 11 step 19: [0.0208578], acc: [1.]
Loss at epoch 12 step 0: [0.56519777], acc: [0.75]
Loss at epoch 12 step 1: [0.0451945], acc: [1.]
Loss at epoch 12 step 2: [0.7147368], acc: [0.75]
Loss at epoch 12 step 3: [0.57219297], acc: [0.875]
Loss at epoch 12 step 4: [0.23464265], acc: [0.875]
Loss at epoch 12 step 5: [0.3478033], acc: [0.875]
Loss at epoch 12 step 6: [0.34062374], acc: [0.75]
Loss at epoch 12 step 7: [0.41367787], acc: [0.625]
Loss at epoch 12 step 8: [0.34609044], acc: [0.75]
Loss at epoch 12 step 9: [0.07610585], acc: [1.]
Loss at epoch 12 step 10: [0.2529419], acc: [0.875]
Loss at epoch 12 step 11: [0.09432285], acc: [1.]
Loss at epoch 12 step 12: [0.13576025], acc: [0.875]
Loss at epoch 12 step 13: [0.13004233], acc: [1.]
Loss at epoch 12 step 14: [0.4061207], acc: [0.875]
Loss at epoch 12 step 15: [0.41558465], acc: [0.875]
Loss at epoch 12 step 16: [0.02463109], acc: [1.]
Loss at epoch 12 step 17: [0.11708587], acc: [0.875]
Loss at epoch 12 step 18: [0.22433802], acc: [0.875]
Loss at epoch 12 step 19: [0.04402123], acc: [1.]
Loss at epoch 13 step 0: [0.15190263], acc: [1.]
Loss at epoch 13 step 1: [0.03397874], acc: [1.]
Loss at epoch 13 step 2: [0.46476182], acc: [0.875]
Loss at epoch 13 step 3: [0.09925576], acc: [1.]
Loss at epoch 13 step 4: [0.18864141], acc: [1.]
Loss at epoch 13 step 5: [0.29506725], acc: [0.875]
Loss at epoch 13 step 6: [0.04077023], acc: [1.]
Loss at epoch 13 step 7: [0.37588683], acc: [0.875]
Loss at epoch 13 step 8: [0.03166682], acc: [1.]
Loss at epoch 13 step 9: [0.01556], acc: [1.]
Loss at epoch 13 step 10: [0.04184946], acc: [1.]
Loss at epoch 13 step 11: [0.02698917], acc: [1.]
Loss at epoch 13 step 12: [0.05659904], acc: [1.]
Loss at epoch 13 step 13: [0.02040308], acc: [1.]
Loss at epoch 13 step 14: [0.6636281], acc: [0.75]
Loss at epoch 13 step 15: [0.0113409], acc: [1.]
Loss at epoch 13 step 16: [0.02159831], acc: [1.]
Loss at epoch 13 step 17: [0.04045048], acc: [1.]
Loss at epoch 13 step 18: [0.04067406], acc: [1.]
Loss at epoch 13 step 19: [0.04184075], acc: [1.]
Loss at epoch 14 step 0: [0.09169513], acc: [1.]
Loss at epoch 14 step 1: [0.42706335], acc: [0.875]
Loss at epoch 14 step 2: [0.12570785], acc: [0.875]
Loss at epoch 14 step 3: [0.05320014], acc: [1.]
Loss at epoch 14 step 4: [0.1517471], acc: [0.875]
Loss at epoch 14 step 5: [0.08652061], acc: [1.]
Loss at epoch 14 step 6: [0.10162817], acc: [1.]
Loss at epoch 14 step 7: [0.6184722], acc: [0.875]
Loss at epoch 14 step 8: [0.00311388], acc: [1.]
Loss at epoch 14 step 9: [0.00679844], acc: [1.]
Loss at epoch 14 step 10: [0.01277756], acc: [1.]
Loss at epoch 14 step 11: [0.0013589], acc: [1.]
Loss at epoch 14 step 12: [0.00514234], acc: [1.]
Loss at epoch 14 step 13: [0.00074283], acc: [1.]
Loss at epoch 14 step 14: [0.03934909], acc: [1.]
Loss at epoch 14 step 15: [0.00095923], acc: [1.]
Loss at epoch 14 step 16: [0.00062678], acc: [1.]
Loss at epoch 14 step 17: [0.01323172], acc: [1.]
Loss at epoch 14 step 18: [0.00603865], acc: [1.]
Loss at epoch 14 step 19: [0.00275196], acc: [1.]
Loss at epoch 15 step 0: [0.03726139], acc: [1.]
Loss at epoch 15 step 1: [0.00019575], acc: [1.]
Loss at epoch 15 step 2: [0.09685334], acc: [0.875]
Loss at epoch 15 step 3: [0.00569768], acc: [1.]
Loss at epoch 15 step 4: [0.28962183], acc: [0.875]
Loss at epoch 15 step 5: [0.00231538], acc: [1.]
Loss at epoch 15 step 6: [0.0014269], acc: [1.]
Loss at epoch 15 step 7: [0.11006889], acc: [0.875]
Loss at epoch 15 step 8: [0.00077758], acc: [1.]
Loss at epoch 15 step 9: [0.00359384], acc: [1.]
Loss at epoch 15 step 10: [0.05332552], acc: [1.]
Loss at epoch 15 step 11: [0.00153383], acc: [1.]
Loss at epoch 15 step 12: [0.01265999], acc: [1.]
Loss at epoch 15 step 13: [0.00478925], acc: [1.]
Loss at epoch 15 step 14: [0.00887071], acc: [1.]
Loss at epoch 15 step 15: [0.00245221], acc: [1.]
Loss at epoch 15 step 16: [0.00385192], acc: [1.]
Loss at epoch 15 step 17: [0.00702642], acc: [1.]
Loss at epoch 15 step 18: [0.01628981], acc: [1.]
Loss at epoch 15 step 19: [0.00411135], acc: [1.]
Loss at epoch 16 step 0: [0.301621], acc: [0.875]
Loss at epoch 16 step 1: [0.00224061], acc: [1.]
Loss at epoch 16 step 2: [0.01487829], acc: [1.]
Loss at epoch 16 step 3: [0.18041733], acc: [0.875]
Loss at epoch 16 step 4: [0.01538774], acc: [1.]
Loss at epoch 16 step 5: [0.02495383], acc: [1.]
Loss at epoch 16 step 6: [0.18342055], acc: [0.875]
Loss at epoch 16 step 7: [0.2386323], acc: [0.875]
Loss at epoch 16 step 8: [0.0110419], acc: [1.]
Loss at epoch 16 step 9: [0.01546003], acc: [1.]
Loss at epoch 16 step 10: [0.00172335], acc: [1.]
Loss at epoch 16 step 11: [0.00120932], acc: [1.]
Loss at epoch 16 step 12: [0.14743163], acc: [0.875]
Loss at epoch 16 step 13: [0.00128715], acc: [1.]
Loss at epoch 16 step 14: [0.02658574], acc: [1.]
Loss at epoch 16 step 15: [0.00175886], acc: [1.]
Loss at epoch 16 step 16: [0.01390693], acc: [1.]
Loss at epoch 16 step 17: [0.03028705], acc: [1.]
Loss at epoch 16 step 18: [0.00257837], acc: [1.]
Loss at epoch 16 step 19: [0.01763894], acc: [1.]
Loss at epoch 17 step 0: [0.02438416], acc: [1.]
Loss at epoch 17 step 1: [4.753505e-06], acc: [1.]
Loss at epoch 17 step 2: [0.0017831], acc: [1.]
Loss at epoch 17 step 3: [0.8114313], acc: [0.875]
Loss at epoch 17 step 4: [0.23217294], acc: [0.875]
Loss at epoch 17 step 5: [0.3747878], acc: [0.875]
Loss at epoch 17 step 6: [0.62509114], acc: [0.75]
Loss at epoch 17 step 7: [0.02011108], acc: [1.]
Loss at epoch 17 step 8: [0.01517871], acc: [1.]
Loss at epoch 17 step 9: [0.45669764], acc: [0.75]
Loss at epoch 17 step 10: [0.11066487], acc: [1.]
Loss at epoch 17 step 11: [0.0129114], acc: [1.]
Loss at epoch 17 step 12: [0.18949813], acc: [0.875]
Loss at epoch 17 step 13: [0.02484129], acc: [1.]
Loss at epoch 17 step 14: [0.01677222], acc: [1.]
Loss at epoch 17 step 15: [0.00922782], acc: [1.]
Loss at epoch 17 step 16: [0.14938074], acc: [0.875]
Loss at epoch 17 step 17: [0.25863168], acc: [0.875]
Loss at epoch 17 step 18: [0.12780228], acc: [0.875]
Loss at epoch 17 step 19: [0.6573757], acc: [0.75]
Loss at epoch 18 step 0: [0.9736184], acc: [0.75]
Loss at epoch 18 step 1: [0.0128655], acc: [1.]
Loss at epoch 18 step 2: [0.11701], acc: [0.875]
Loss at epoch 18 step 3: [0.59538484], acc: [0.875]
Loss at epoch 18 step 4: [0.3027583], acc: [0.875]
Loss at epoch 18 step 5: [0.32849047], acc: [0.875]
Loss at epoch 18 step 6: [0.14853735], acc: [0.875]
Loss at epoch 18 step 7: [0.2717516], acc: [0.875]
Loss at epoch 18 step 8: [0.2153818], acc: [1.]
Loss at epoch 18 step 9: [0.1480442], acc: [1.]
Loss at epoch 18 step 10: [0.5436878], acc: [0.875]
Loss at epoch 18 step 11: [0.07038119], acc: [1.]
Loss at epoch 18 step 12: [0.13259311], acc: [0.875]
Loss at epoch 18 step 13: [0.04160739], acc: [1.]
Loss at epoch 18 step 14: [0.11504561], acc: [1.]
Loss at epoch 18 step 15: [0.12963216], acc: [1.]
Loss at epoch 18 step 16: [0.01204668], acc: [1.]
Loss at epoch 18 step 17: [0.03431289], acc: [1.]
Loss at epoch 18 step 18: [0.27396902], acc: [0.875]
Loss at epoch 18 step 19: [0.01383034], acc: [1.]
Loss at epoch 19 step 0: [0.25969458], acc: [0.875]
Loss at epoch 19 step 1: [0.43647614], acc: [0.875]
Loss at epoch 19 step 2: [0.04337307], acc: [1.]
Loss at epoch 19 step 3: [0.5940319], acc: [0.875]
Loss at epoch 19 step 4: [0.22873557], acc: [0.875]
Loss at epoch 19 step 5: [0.15333156], acc: [0.875]
Loss at epoch 19 step 6: [0.01617015], acc: [1.]
Loss at epoch 19 step 7: [0.15397456], acc: [0.875]
Loss at epoch 19 step 8: [0.07153313], acc: [1.]
Loss at epoch 19 step 9: [0.09117234], acc: [1.]
Loss at epoch 19 step 10: [0.17218468], acc: [0.875]
Loss at epoch 19 step 11: [0.02451311], acc: [1.]
Loss at epoch 19 step 12: [0.10338892], acc: [1.]
Loss at epoch 19 step 13: [0.46306562], acc: [0.75]
Loss at epoch 19 step 14: [0.2109108], acc: [0.875]
Loss at epoch 19 step 15: [0.03004335], acc: [1.]
Loss at epoch 19 step 16: [0.08905614], acc: [1.]
Loss at epoch 19 step 17: [0.3149104], acc: [0.875]
Loss at epoch 19 step 18: [0.2007995], acc: [0.875]
Loss at epoch 19 step 19: [0.22692351], acc: [0.875]
Loss at epoch 20 step 0: [0.19369325], acc: [0.875]
Loss at epoch 20 step 1: [0.00322215], acc: [1.]
Loss at epoch 20 step 2: [0.479892], acc: [0.875]
Loss at epoch 20 step 3: [0.08493809], acc: [1.]
Loss at epoch 20 step 4: [0.12284801], acc: [0.875]
Loss at epoch 20 step 5: [0.24773014], acc: [0.75]
Loss at epoch 20 step 6: [0.01091109], acc: [1.]
Loss at epoch 20 step 7: [0.32423535], acc: [0.875]
Loss at epoch 20 step 8: [0.02481262], acc: [1.]
Loss at epoch 20 step 9: [0.04488695], acc: [1.]
Loss at epoch 20 step 10: [0.00709584], acc: [1.]
Loss at epoch 20 step 11: [0.01180508], acc: [1.]
Loss at epoch 20 step 12: [0.01547016], acc: [1.]
Loss at epoch 20 step 13: [0.00494665], acc: [1.]
Loss at epoch 20 step 14: [0.03496835], acc: [1.]
Loss at epoch 20 step 15: [0.04730208], acc: [1.]
Loss at epoch 20 step 16: [0.01454387], acc: [1.]
Loss at epoch 20 step 17: [6.2246945e-05], acc: [1.]
Loss at epoch 20 step 18: [0.39170966], acc: [0.75]
Loss at epoch 20 step 19: [0.00470556], acc: [1.]
Loss at epoch 21 step 0: [0.73801553], acc: [0.75]
Loss at epoch 21 step 1: [0.00661279], acc: [1.]
Loss at epoch 21 step 2: [0.5532548], acc: [0.875]
Loss at epoch 21 step 3: [0.11707169], acc: [1.]
Loss at epoch 21 step 4: [0.00863592], acc: [1.]
Loss at epoch 21 step 5: [0.16955887], acc: [0.875]
Loss at epoch 21 step 6: [0.06254207], acc: [1.]
Loss at epoch 21 step 7: [0.06522679], acc: [1.]
Loss at epoch 21 step 8: [0.03758458], acc: [1.]
Loss at epoch 21 step 9: [0.0066552], acc: [1.]
Loss at epoch 21 step 10: [0.01098488], acc: [1.]
Loss at epoch 21 step 11: [0.16182472], acc: [0.875]
Loss at epoch 21 step 12: [0.01966172], acc: [1.]
Loss at epoch 21 step 13: [0.0003975], acc: [1.]
Loss at epoch 21 step 14: [0.5464499], acc: [0.625]
Loss at epoch 21 step 15: [0.00045486], acc: [1.]
Loss at epoch 21 step 16: [0.01067102], acc: [1.]
Loss at epoch 21 step 17: [0.00013679], acc: [1.]
Loss at epoch 21 step 18: [0.01584426], acc: [1.]
Loss at epoch 21 step 19: [0.03529365], acc: [1.]
Loss at epoch 22 step 0: [0.14717121], acc: [0.875]
Loss at epoch 22 step 1: [0.00441175], acc: [1.]
Loss at epoch 22 step 2: [0.01598742], acc: [1.]
Loss at epoch 22 step 3: [0.3904212], acc: [0.875]
Loss at epoch 22 step 4: [0.00783232], acc: [1.]
Loss at epoch 22 step 5: [0.26543722], acc: [0.875]
Loss at epoch 22 step 6: [0.00183485], acc: [1.]
Loss at epoch 22 step 7: [0.02409321], acc: [1.]
Loss at epoch 22 step 8: [0.04156028], acc: [1.]
Loss at epoch 22 step 9: [0.00147904], acc: [1.]
Loss at epoch 22 step 10: [0.29658732], acc: [0.875]
Loss at epoch 22 step 11: [0.4006066], acc: [0.875]
Loss at epoch 22 step 12: [0.1133399], acc: [1.]
Loss at epoch 22 step 13: [0.00256825], acc: [1.]
Loss at epoch 22 step 14: [0.15013503], acc: [0.875]
Loss at epoch 22 step 15: [0.00381611], acc: [1.]
Loss at epoch 22 step 16: [0.00935294], acc: [1.]
Loss at epoch 22 step 17: [0.01014361], acc: [1.]
Loss at epoch 22 step 18: [0.05148259], acc: [1.]
Loss at epoch 22 step 19: [0.05351965], acc: [1.]
Loss at epoch 23 step 0: [0.01875822], acc: [1.]
Loss at epoch 23 step 1: [0.01686215], acc: [1.]
Loss at epoch 23 step 2: [0.24428883], acc: [0.875]
Loss at epoch 23 step 3: [0.04918946], acc: [1.]
Loss at epoch 23 step 4: [0.0677656], acc: [1.]
Loss at epoch 23 step 5: [0.00169005], acc: [1.]
Loss at epoch 23 step 6: [0.00875748], acc: [1.]
Loss at epoch 23 step 7: [0.44426045], acc: [0.875]
Loss at epoch 23 step 8: [0.00027349], acc: [1.]
Loss at epoch 23 step 9: [0.00043996], acc: [1.]
Loss at epoch 23 step 10: [0.00294974], acc: [1.]
Loss at epoch 23 step 11: [0.00097874], acc: [1.]
Loss at epoch 23 step 12: [0.00103066], acc: [1.]
Loss at epoch 23 step 13: [0.03459955], acc: [1.]
Loss at epoch 23 step 14: [0.00300348], acc: [1.]
Loss at epoch 23 step 15: [0.0036058], acc: [1.]
Loss at epoch 23 step 16: [0.00226042], acc: [1.]
Loss at epoch 23 step 17: [0.00443218], acc: [1.]
Loss at epoch 23 step 18: [0.13676935], acc: [0.875]
Loss at epoch 23 step 19: [0.0036195], acc: [1.]
Loss at epoch 24 step 0: [0.31144148], acc: [0.875]
Loss at epoch 24 step 1: [0.00144199], acc: [1.]
Loss at epoch 24 step 2: [0.03611071], acc: [1.]
Loss at epoch 24 step 3: [0.03871601], acc: [1.]
Loss at epoch 24 step 4: [0.01051426], acc: [1.]
Loss at epoch 24 step 5: [0.08505414], acc: [1.]
Loss at epoch 24 step 6: [1.223389], acc: [0.875]
Loss at epoch 24 step 7: [0.05714148], acc: [1.]
Loss at epoch 24 step 8: [0.01579988], acc: [1.]
Loss at epoch 24 step 9: [0.07242982], acc: [1.]
Loss at epoch 24 step 10: [0.07992741], acc: [1.]
Loss at epoch 24 step 11: [0.04183127], acc: [1.]
Loss at epoch 24 step 12: [0.12689956], acc: [0.875]
Loss at epoch 24 step 13: [0.02283078], acc: [1.]
Loss at epoch 24 step 14: [0.2377506], acc: [0.75]
Loss at epoch 24 step 15: [0.00890957], acc: [1.]
Loss at epoch 24 step 16: [0.00279929], acc: [1.]
Loss at epoch 24 step 17: [2.2449121], acc: [0.75]
Loss at epoch 24 step 18: [0.04785965], acc: [1.]
Loss at epoch 24 step 19: [0.13292599], acc: [1.]
Loss at epoch 25 step 0: [0.10696022], acc: [1.]
Loss at epoch 25 step 1: [0.00429973], acc: [1.]
Loss at epoch 25 step 2: [0.0042081], acc: [1.]
Loss at epoch 25 step 3: [1.9758257], acc: [0.75]
Loss at epoch 25 step 4: [0.171402], acc: [0.875]
Loss at epoch 25 step 5: [0.12759587], acc: [1.]
Loss at epoch 25 step 6: [0.2663746], acc: [0.75]
Loss at epoch 25 step 7: [0.23906492], acc: [0.875]
Loss at epoch 25 step 8: [0.14136526], acc: [1.]
Loss at epoch 25 step 9: [0.47031033], acc: [0.75]
Loss at epoch 25 step 10: [0.29648155], acc: [0.875]
Loss at epoch 25 step 11: [0.07526504], acc: [1.]
Loss at epoch 25 step 12: [0.4687659], acc: [0.75]
Loss at epoch 25 step 13: [0.02652491], acc: [1.]
Loss at epoch 25 step 14: [0.1879304], acc: [0.875]
Loss at epoch 25 step 15: [0.52559847], acc: [0.875]
Loss at epoch 25 step 16: [0.10688182], acc: [0.875]
Loss at epoch 25 step 17: [0.04024434], acc: [1.]
Loss at epoch 25 step 18: [0.29196358], acc: [0.875]
Loss at epoch 25 step 19: [0.2228569], acc: [0.875]
Loss at epoch 26 step 0: [0.65764683], acc: [0.625]
Loss at epoch 26 step 1: [0.02769414], acc: [1.]
Loss at epoch 26 step 2: [0.30497324], acc: [0.875]
Loss at epoch 26 step 3: [0.39395043], acc: [0.875]
Loss at epoch 26 step 4: [0.06476444], acc: [1.]
Loss at epoch 26 step 5: [0.27351773], acc: [0.875]
Loss at epoch 26 step 6: [0.0290995], acc: [1.]
Loss at epoch 26 step 7: [0.08524988], acc: [1.]
Loss at epoch 26 step 8: [0.17496032], acc: [1.]
Loss at epoch 26 step 9: [0.06341403], acc: [1.]
Loss at epoch 26 step 10: [0.03769329], acc: [1.]
Loss at epoch 26 step 11: [0.00901257], acc: [1.]
Loss at epoch 26 step 12: [0.07382029], acc: [1.]
Loss at epoch 26 step 13: [0.13795148], acc: [0.875]
Loss at epoch 26 step 14: [0.04730515], acc: [1.]
Loss at epoch 26 step 15: [0.01458132], acc: [1.]
Loss at epoch 26 step 16: [0.00823013], acc: [1.]
Loss at epoch 26 step 17: [0.00734012], acc: [1.]
Loss at epoch 26 step 18: [0.34702942], acc: [0.875]
Loss at epoch 26 step 19: [0.05200786], acc: [1.]
Loss at epoch 27 step 0: [0.01351643], acc: [1.]
Loss at epoch 27 step 1: [0.00240216], acc: [1.]
Loss at epoch 27 step 2: [0.00541603], acc: [1.]
Loss at epoch 27 step 3: [1.1008576], acc: [0.875]
Loss at epoch 27 step 4: [0.08875335], acc: [1.]
Loss at epoch 27 step 5: [0.29341292], acc: [0.875]
Loss at epoch 27 step 6: [0.00303972], acc: [1.]
Loss at epoch 27 step 7: [0.02141408], acc: [1.]
Loss at epoch 27 step 8: [0.07996958], acc: [1.]
Loss at epoch 27 step 9: [0.03656019], acc: [1.]
Loss at epoch 27 step 10: [0.40547], acc: [0.875]
Loss at epoch 27 step 11: [0.03472169], acc: [1.]
Loss at epoch 27 step 12: [0.24486515], acc: [0.875]
Loss at epoch 27 step 13: [0.2517213], acc: [0.875]
Loss at epoch 27 step 14: [0.1099641], acc: [1.]
Loss at epoch 27 step 15: [0.05793203], acc: [1.]
Loss at epoch 27 step 16: [0.07681417], acc: [1.]
Loss at epoch 27 step 17: [0.02409343], acc: [1.]
Loss at epoch 27 step 18: [0.47336364], acc: [0.875]
Loss at epoch 27 step 19: [0.35610297], acc: [0.875]
Loss at epoch 28 step 0: [0.20905192], acc: [0.875]
Loss at epoch 28 step 1: [0.01897191], acc: [1.]
Loss at epoch 28 step 2: [0.04165654], acc: [1.]
Loss at epoch 28 step 3: [1.0690848], acc: [0.75]
Loss at epoch 28 step 4: [0.10241486], acc: [0.875]
Loss at epoch 28 step 5: [0.0215333], acc: [1.]
Loss at epoch 28 step 6: [0.01466263], acc: [1.]
Loss at epoch 28 step 7: [0.17665865], acc: [0.875]
Loss at epoch 28 step 8: [0.00079305], acc: [1.]
Loss at epoch 28 step 9: [0.04661468], acc: [1.]
Loss at epoch 28 step 10: [0.05581912], acc: [1.]
Loss at epoch 28 step 11: [1.9144715], acc: [0.75]
Loss at epoch 28 step 12: [0.01354441], acc: [1.]
Loss at epoch 28 step 13: [0.12006256], acc: [0.875]
Loss at epoch 28 step 14: [0.00485796], acc: [1.]
Loss at epoch 28 step 15: [0.4155366], acc: [0.875]
Loss at epoch 28 step 16: [0.02007511], acc: [1.]
Loss at epoch 28 step 17: [0.00023603], acc: [1.]
Loss at epoch 28 step 18: [0.26743862], acc: [0.875]
Loss at epoch 28 step 19: [0.2703232], acc: [0.875]
Loss at epoch 29 step 0: [0.23318593], acc: [0.875]
Loss at epoch 29 step 1: [0.26718912], acc: [0.875]
Loss at epoch 29 step 2: [0.06375959], acc: [1.]
Loss at epoch 29 step 3: [0.19476566], acc: [0.875]
Loss at epoch 29 step 4: [1.0634948], acc: [0.75]
Loss at epoch 29 step 5: [0.03109117], acc: [1.]
Loss at epoch 29 step 6: [0.01919413], acc: [1.]
Loss at epoch 29 step 7: [0.44029456], acc: [0.75]
Loss at epoch 29 step 8: [0.28687736], acc: [0.875]
Loss at epoch 29 step 9: [0.23254272], acc: [0.75]
Loss at epoch 29 step 10: [0.22356018], acc: [1.]
Loss at epoch 29 step 11: [0.30657366], acc: [0.875]
Loss at epoch 29 step 12: [0.06665707], acc: [1.]
Loss at epoch 29 step 13: [0.05950367], acc: [1.]
Loss at epoch 29 step 14: [0.06584864], acc: [1.]
Loss at epoch 29 step 15: [0.08399688], acc: [1.]
Loss at epoch 29 step 16: [0.0184287], acc: [1.]
Loss at epoch 29 step 17: [0.02334027], acc: [1.]
Loss at epoch 29 step 18: [0.06455258], acc: [1.]
Loss at epoch 29 step 19: [0.02999917], acc: [1.]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NSl8iNzf-1586356079630)(output_15_1.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kfC4nPfI-1586356079631)(output_15_2.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-R6cg7QeW-1586356079633)(output_15_3.png)]
Final loss: [0.02999917]
'''
模型校验
'''
with fluid.dygraph.guard():
model, _ = fluid.load_dygraph("vgg")
vgg = VGGNet()
vgg.load_dict(model)
vgg.eval()
accs = []
for batch_id, data in enumerate(eval_reader()):
dy_x_data = np.array([x[0] for x in data]).astype('float32')
y_data = np.array([x[1] for x in data]).astype('int')
y_data = y_data[:, np.newaxis]
img = fluid.dygraph.to_variable(dy_x_data)
label = fluid.dygraph.to_variable(y_data)
out, acc = vgg(img, label)
lab = np.argsort(out.numpy())
accs.append(acc.numpy()[0])
print(np.mean(accs))
0.9375
def load_image(img_path):
'''
预测图片预处理
'''
img = Image.open(img_path)
if img.mode != 'RGB':
img = img.convert('RGB')
img = img.resize((224, 224), Image.BILINEAR)
img = np.array(img).astype('float32')
img = img.transpose((2, 0, 1)) # HWC to CHW
img = img/255 # 像素值归一化
return img
label_dic = train_parameters['label_dict']
'''
模型预测
'''
with fluid.dygraph.guard():
model, _ = fluid.dygraph.load_dygraph("vgg")
vgg = VGGNet()
vgg.load_dict(model)
vgg.eval()
#展示预测图片
#infer_path='/home/aistudio/data/data23615/infer_mask01.jpg'
infer_path='/home/aistudio/data/data23615/infer_mask02.jpg'
img = Image.open(infer_path)
plt.imshow(img) #根据数组绘制图像
plt.show() #显示图像
#对预测图片进行预处理
infer_imgs = []
infer_imgs.append(load_image(infer_path))
infer_imgs = np.array(infer_imgs)
for i in range(len(infer_imgs)):
data = infer_imgs[i]
dy_x_data = np.array(data).astype('float32')
dy_x_data=dy_x_data[np.newaxis,:, : ,:]
img = fluid.dygraph.to_variable(dy_x_data)
out = vgg(img)
lab = np.argmax(out.numpy()) #argmax():返回最大数的索引
print("第{}个样本,被预测为:{}".format(i+1,label_dic[str(lab)]))
print("结束")
第1个样本,被预测为:maskimages
结束
更多请参考: