使用TensorFlow keras搭建神经网络实现牛奶质量分类

本文通过TensorFlow框架中的keras构建简单神经网络对牛奶质量进行分类(预测),具有较高的准确率,下面进行详细的介绍。

文章目录

    • 数据集介绍
    • 分类过程介绍
    • 总结与分析

数据集介绍

数据集的来源为kaggle网站,地址为https://www.kaggle.com/datasets/cpluzshrijayan/milkquality
在此感谢数据集的作者,大家可自行下载。

  • 该数据集为人工观测收集,可用于构建机器学习模型来预测牛奶的质量。
  • 该数据集由pH值、温度、味道、气味、脂肪、浊度和颜色7个特征组成。
  • 在一般情况下,牛奶质量取决于这些特征参数,可用于预测牛奶的质量。

标签值分为3类,分别是low、medium、high,以此来区分牛奶的质量。

分类过程介绍

首先读取实验数据集并进行处理
由于数据集标签列中为字符串类型,为了便于实验,首先将标签值转换为数值类型。
转换的规则为:
low = 0
medium = 1
high = 2
处理后输出数据集

import pandas as pd
import tensorflow as tf
import numpy as np

# 读取数据集并处理
read_data = pd.read_csv('milknew.csv')
# 读取进来的csv文件
print('显示读取进来的csv文件:\n', read_data)
# 使用to_string()可以输出全部数据,否则只能输出前五行和后五行数据,中间数据以...代替
# print(read_data.to_string())
# 读取csv文件值
print('读取csv文件的值:\n', read_data.values)
# 读取csv文件中'Grade'列的值
data_Grade = read_data['Grade'].values
print('读取csv文件中【Grade】列的值:\n', data_Grade)
# 将csv文件中'Grade'列的值由字符串型变为数值型
'''
low = 0
medium = 1
high = 2
'''
for _, grade in enumerate(data_Grade):
    # print(_, grade)
    if grade == 'low':
        data_Grade[_] = 0
    elif grade == 'medium':
        data_Grade[_] = 1
    elif grade == 'high':
        data_Grade[_] = 2
print('更新后csv文件中【Grade】列的值:\n',data_Grade)
read_data['Grade'] = data_Grade
#print(read_data['Grade'])
# 处理后的数据集文件
datasets = read_data
print('处理后的数据集文件:\n', datasets)
# print(f'数据集有{datasets.shape[0]}行')
# print(f'数据集有{datasets.shape[1]}列')
显示读取进来的csv文件:
        pH  Temprature  Taste  Odor  Fat   Turbidity  Colour   Grade
0     6.6          35      1     0     1          0     254    high
1     6.6          36      0     1     0          1     253    high
2     8.5          70      1     1     1          1     246     low
3     9.5          34      1     1     0          1     255     low
4     6.6          37      0     0     0          0     255  medium
...   ...         ...    ...   ...   ...        ...     ...     ...
1054  6.7          45      1     1     0          0     247  medium
1055  6.7          38      1     0     1          0     255    high
1056  3.0          40      1     1     1          1     255     low
1057  6.8          43      1     0     1          0     250    high
1058  8.6          55      0     1     1          1     255     low

[1059 rows x 8 columns]
读取csv文件的值:
 [[6.6 35 1 ... 0 254 'high']
 [6.6 36 0 ... 1 253 'high']
 [8.5 70 1 ... 1 246 'low']
 ...
 [3.0 40 1 ... 1 255 'low']
 [6.8 43 1 ... 0 250 'high']
 [8.6 55 0 ... 1 255 'low']]
读取csv文件中【Grade】列的值:
 ['high' 'high' 'low' ... 'low' 'high' 'low']
更新后csv文件中【Grade】列的值:
 [2 2 0 ... 0 2 0]
处理后的数据集文件:
        pH  Temprature  Taste  Odor  Fat   Turbidity  Colour Grade
0     6.6          35      1     0     1          0     254     2
1     6.6          36      0     1     0          1     253     2
2     8.5          70      1     1     1          1     246     0
3     9.5          34      1     1     0          1     255     0
4     6.6          37      0     0     0          0     255     1
...   ...         ...    ...   ...   ...        ...     ...   ...
1054  6.7          45      1     1     0          0     247     1
1055  6.7          38      1     0     1          0     255     2
1056  3.0          40      1     1     1          1     255     0
1057  6.8          43      1     0     1          0     250     2
1058  8.6          55      0     1     1          1     255     0

[1059 rows x 8 columns]

便于实验方便,将上述数据集中的特征列与标签列分别提取出来,在提取过程中发现标签列为object类型,不便于后续训练模型,所以此处将标签列转换为int类型。

# 将训练集的特征和标签提取出来
# 提取特征列
features_data = datasets.iloc[:,:-1].values # 提取全部行,除最后一列的数据
# 提取标签列
labels_data = datasets.iloc[:,-1:].values # 提取全部行,最后一列的数据
# 下面这种语句也可以实现提取相应的列
# features_data = datasets.iloc[:,:7].values # 提取全部行,前7列的数据
# labels_data = datasets.iloc[:,7:8].values # 提取全部行,最后一列的数据

# print('数据集特征列:\n', features_data)
print('数据集特征列的类型:\n', features_data.dtype)
# print('数据集标签列:\n', labels_data)
print('数据集标签列的类型:\n', labels_data.dtype)
# labels_data.dtype的类型为object,后续训练需要转化为int类型

# 建立一个空的numpy一维矩阵,以便于将labels_data从object型转成int型,用于后续模型训练
labels_data_numpy = np.zeros((1, len(labels_data)))

# 将labels_data数字装进numpy一维矩阵中
for _, label in enumerate(labels_data):
    # print(_, label[0])
    labels_data_numpy[0][_] = label[0]

print("类型转化后的标签列:\n", labels_data_numpy[0])
print("类型转化后的标签列的类型:\n", labels_data_numpy[0].dtype)

# labels_data_np承接类型转化后的标签列,以便于后续操作
labels_data_np = labels_data_numpy[0]

# 将float64类型转化为int32类型
labels_data_np = tf.cast(labels_data_np, tf.int32)

# 为了方便后续操作,依然将处理好的标签列命名为labels_data
labels_data = labels_data_np

# 输出数据集处理后的结果
print('数据集特征列:\n', features_data)
print('数据集特征列的类型为:\n', features_data.dtype)
print('数据集标签列:\n', labels_data)
print('数据集标签列的类型为:\n', labels_data.dtype)
数据集特征列的类型:
 float64
数据集标签列的类型:
 object
类型转化后的标签列:
 [2. 2. 0. ... 0. 2. 0.]
类型转化后的标签列的类型:
 float64
数据集特征列:
 [[  6.6  35.    1.  ...   1.    0.  254. ]
 [  6.6  36.    0.  ...   0.    1.  253. ]
 [  8.5  70.    1.  ...   1.    1.  246. ]
 ...
 [  3.   40.    1.  ...   1.    1.  255. ]
 [  6.8  43.    1.  ...   1.    0.  250. ]
 [  8.6  55.    0.  ...   1.    1.  255. ]]
数据集特征列的类型为:
 float64
数据集标签列:
 tf.Tensor([2 2 0 ... 0 2 0], shape=(1059,), dtype=int32)
数据集标签列的类型为:
 

下面进行网络结构的搭建,配置和训练模型
网络结构有3层全连接层:
第一层有30个神经元,激活函数为relu
第二层有90个神经元,激活函数为relu
第三层,也是输出层,有3个神经元,激活函数为softmax
网络配置中:
使用Adagrad优化器
学习率为0.1
使用稀疏多分类交叉熵损失函数(SparseCategoricalCrossentropy)
训练过程中:
batch_size设置为32一组
训练轮数epochs设置为500轮
每轮迭代前随机打乱数据样本
验证集占数据集的比例为0.2
每100轮使用验证集验证一次

# 搭建网络结构
model = tf.keras.models.Sequential([
    # 这是一个全连接层,3是神经元个数,kernel_regularizer是选用的正则化方法 
    tf.keras.layers.Dense(30, activation='relu', kernel_regularizer=tf.keras.regularizers.l2()),  
    tf.keras.layers.Dense(90, activation='relu', kernel_regularizer=tf.keras.regularizers.l2()), 
    tf.keras.layers.Dense(3, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2()) 
])
print('网络结构搭建:\n', model)

# 配置训练方法
model.compile(optimizer=tf.keras.optimizers.Adagrad(learning_rate=0.1),
             loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
             metrics=['sparse_categorical_accuracy'])

# 执行训练过程
# validation_split是测试集的比例
# validation_freq表示每迭代多少次训练集就在验证集中验证一次准确率
# batch_size默认为32,也可改成别的数字,一般设置成2的n次方
model.fit(features_data, labels_data ,batch_size=32,epochs=500,shuffle=True,validation_split=0.2,validation_freq=100)
网络结构搭建:
 
Epoch 1/500
27/27 [==============================] - 0s 1ms/step - loss: 22.1251 - sparse_categorical_accuracy: 0.4321
Epoch 2/500
27/27 [==============================] - 0s 997us/step - loss: 1.6387 - sparse_categorical_accuracy: 0.4723
Epoch 3/500
27/27 [==============================] - 0s 1ms/step - loss: 1.3700 - sparse_categorical_accuracy: 0.5301
Epoch 4/500
27/27 [==============================] - 0s 1ms/step - loss: 1.3302 - sparse_categorical_accuracy: 0.5289
Epoch 5/500
27/27 [==============================] - 0s 1ms/step - loss: 1.2542 - sparse_categorical_accuracy: 0.5207
Epoch 6/500
27/27 [==============================] - 0s 1ms/step - loss: 1.2033 - sparse_categorical_accuracy: 0.5230
Epoch 7/500
27/27 [==============================] - 0s 1ms/step - loss: 1.1840 - sparse_categorical_accuracy: 0.5336
Epoch 8/500
27/27 [==============================] - 0s 1ms/step - loss: 1.1732 - sparse_categorical_accuracy: 0.5348
Epoch 9/500
27/27 [==============================] - 0s 1ms/step - loss: 1.1447 - sparse_categorical_accuracy: 0.5348
Epoch 10/500
27/27 [==============================] - 0s 1ms/step - loss: 1.1235 - sparse_categorical_accuracy: 0.5537
Epoch 11/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0977 - sparse_categorical_accuracy: 0.5490
Epoch 12/500
27/27 [==============================] - 0s 892us/step - loss: 1.0848 - sparse_categorical_accuracy: 0.5632
Epoch 13/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0857 - sparse_categorical_accuracy: 0.5490
Epoch 14/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0787 - sparse_categorical_accuracy: 0.5691
Epoch 15/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0580 - sparse_categorical_accuracy: 0.5632
Epoch 16/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0658 - sparse_categorical_accuracy: 0.5809
Epoch 17/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0720 - sparse_categorical_accuracy: 0.5702
Epoch 18/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0424 - sparse_categorical_accuracy: 0.5998
Epoch 19/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0271 - sparse_categorical_accuracy: 0.5880
Epoch 20/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0194 - sparse_categorical_accuracy: 0.6104
Epoch 21/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0232 - sparse_categorical_accuracy: 0.6045
Epoch 22/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0112 - sparse_categorical_accuracy: 0.6116
Epoch 23/500
27/27 [==============================] - 0s 958us/step - loss: 1.0126 - sparse_categorical_accuracy: 0.6234
Epoch 24/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9846 - sparse_categorical_accuracy: 0.6257
Epoch 25/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9905 - sparse_categorical_accuracy: 0.6139
Epoch 26/500
27/27 [==============================] - 0s 1ms/step - loss: 1.0140 - sparse_categorical_accuracy: 0.6057
Epoch 27/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9873 - sparse_categorical_accuracy: 0.6269
Epoch 28/500
27/27 [==============================] - 0s 952us/step - loss: 0.9959 - sparse_categorical_accuracy: 0.6269
Epoch 29/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9571 - sparse_categorical_accuracy: 0.6600
Epoch 30/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9845 - sparse_categorical_accuracy: 0.6246
Epoch 31/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9532 - sparse_categorical_accuracy: 0.6517
Epoch 32/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9519 - sparse_categorical_accuracy: 0.6411
Epoch 33/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9446 - sparse_categorical_accuracy: 0.6730
Epoch 34/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9493 - sparse_categorical_accuracy: 0.6458
Epoch 35/500
27/27 [==============================] - 0s 907us/step - loss: 0.9605 - sparse_categorical_accuracy: 0.6375
Epoch 36/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9292 - sparse_categorical_accuracy: 0.6694
Epoch 37/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9351 - sparse_categorical_accuracy: 0.6553
Epoch 38/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9844 - sparse_categorical_accuracy: 0.6281
Epoch 39/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9111 - sparse_categorical_accuracy: 0.6930
Epoch 40/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9483 - sparse_categorical_accuracy: 0.6600
Epoch 41/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9050 - sparse_categorical_accuracy: 0.6753
Epoch 42/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9191 - sparse_categorical_accuracy: 0.6765
Epoch 43/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9438 - sparse_categorical_accuracy: 0.6588
Epoch 44/500
27/27 [==============================] - 0s 956us/step - loss: 0.8847 - sparse_categorical_accuracy: 0.7273
Epoch 45/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9330 - sparse_categorical_accuracy: 0.6635
Epoch 46/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9123 - sparse_categorical_accuracy: 0.6824
Epoch 47/500
27/27 [==============================] - 0s 934us/step - loss: 0.8701 - sparse_categorical_accuracy: 0.7285
Epoch 48/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8512 - sparse_categorical_accuracy: 0.7214
Epoch 49/500
27/27 [==============================] - 0s 905us/step - loss: 0.8901 - sparse_categorical_accuracy: 0.7226
Epoch 50/500
27/27 [==============================] - 0s 918us/step - loss: 0.9285 - sparse_categorical_accuracy: 0.6812
Epoch 51/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8719 - sparse_categorical_accuracy: 0.7131
Epoch 52/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8747 - sparse_categorical_accuracy: 0.7344
Epoch 53/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8510 - sparse_categorical_accuracy: 0.7367
Epoch 54/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8178 - sparse_categorical_accuracy: 0.7591
Epoch 55/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8557 - sparse_categorical_accuracy: 0.7237
Epoch 56/500
27/27 [==============================] - 0s 962us/step - loss: 0.8976 - sparse_categorical_accuracy: 0.6930
Epoch 57/500
27/27 [==============================] - 0s 1ms/step - loss: 0.9161 - sparse_categorical_accuracy: 0.6812
Epoch 58/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8566 - sparse_categorical_accuracy: 0.7285
Epoch 59/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8546 - sparse_categorical_accuracy: 0.7414
Epoch 60/500
27/27 [==============================] - 0s 980us/step - loss: 0.8403 - sparse_categorical_accuracy: 0.7438
Epoch 61/500
27/27 [==============================] - 0s 997us/step - loss: 0.8893 - sparse_categorical_accuracy: 0.6777
Epoch 62/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8692 - sparse_categorical_accuracy: 0.7096
Epoch 63/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8341 - sparse_categorical_accuracy: 0.7296
Epoch 64/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8447 - sparse_categorical_accuracy: 0.7332
Epoch 65/500
27/27 [==============================] - 0s 976us/step - loss: 0.8475 - sparse_categorical_accuracy: 0.7084
Epoch 66/500
27/27 [==============================] - 0s 971us/step - loss: 0.8363 - sparse_categorical_accuracy: 0.7414
Epoch 67/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8759 - sparse_categorical_accuracy: 0.6848
Epoch 68/500
27/27 [==============================] - 0s 1ms/step - loss: 0.8390 - sparse_categorical_accuracy: 0.7296
Epoch 69/500
27/27 [==============================] - 0s 973us/step - loss: 0.7926 - sparse_categorical_accuracy: 0.7414
Epoch 70/500
27/27 [==============================] - 0s 989us/step - loss: 0.8728 - sparse_categorical_accuracy: 0.7013
Epoch 71/500
27/27 [==============================] - 0s 943us/step - loss: 0.8297 - sparse_categorical_accuracy: 0.7214
Epoch 72/500
27/27 [==============================] - 0s 961us/step - loss: 0.8263 - sparse_categorical_accuracy: 0.7285
Epoch 73/500
27/27 [==============================] - 0s 874us/step - loss: 0.8179 - sparse_categorical_accuracy: 0.7332
Epoch 74/500
27/27 [==============================] - 0s 908us/step - loss: 0.8657 - sparse_categorical_accuracy: 0.7119
Epoch 75/500
27/27 [==============================] - 0s 884us/step - loss: 0.7939 - sparse_categorical_accuracy: 0.7414
Epoch 76/500
27/27 [==============================] - 0s 914us/step - loss: 0.7630 - sparse_categorical_accuracy: 0.7733
Epoch 77/500
27/27 [==============================] - 0s 984us/step - loss: 0.7445 - sparse_categorical_accuracy: 0.7922
Epoch 78/500
27/27 [==============================] - 0s 882us/step - loss: 0.7866 - sparse_categorical_accuracy: 0.7651
Epoch 79/500
27/27 [==============================] - 0s 891us/step - loss: 0.7754 - sparse_categorical_accuracy: 0.7627
Epoch 80/500
27/27 [==============================] - 0s 911us/step - loss: 0.7940 - sparse_categorical_accuracy: 0.7627
Epoch 81/500
27/27 [==============================] - 0s 957us/step - loss: 0.7881 - sparse_categorical_accuracy: 0.7603
Epoch 82/500
27/27 [==============================] - 0s 1ms/step - loss: 0.7544 - sparse_categorical_accuracy: 0.7757
Epoch 83/500
27/27 [==============================] - 0s 931us/step - loss: 0.7647 - sparse_categorical_accuracy: 0.7733
Epoch 84/500
27/27 [==============================] - 0s 964us/step - loss: 0.7464 - sparse_categorical_accuracy: 0.7863
Epoch 85/500
27/27 [==============================] - 0s 895us/step - loss: 0.8166 - sparse_categorical_accuracy: 0.7273
Epoch 86/500
27/27 [==============================] - 0s 888us/step - loss: 0.7509 - sparse_categorical_accuracy: 0.7839
Epoch 87/500
27/27 [==============================] - 0s 891us/step - loss: 0.7769 - sparse_categorical_accuracy: 0.7438
Epoch 88/500
27/27 [==============================] - 0s 951us/step - loss: 0.7473 - sparse_categorical_accuracy: 0.7804
Epoch 89/500
27/27 [==============================] - 0s 988us/step - loss: 0.7138 - sparse_categorical_accuracy: 0.8111
Epoch 90/500
27/27 [==============================] - 0s 918us/step - loss: 0.7360 - sparse_categorical_accuracy: 0.7910
Epoch 91/500
27/27 [==============================] - 0s 904us/step - loss: 0.7179 - sparse_categorical_accuracy: 0.7946
Epoch 92/500
27/27 [==============================] - 0s 908us/step - loss: 0.6990 - sparse_categorical_accuracy: 0.8288
Epoch 93/500
27/27 [==============================] - 0s 925us/step - loss: 0.7166 - sparse_categorical_accuracy: 0.8064
Epoch 94/500
27/27 [==============================] - 0s 913us/step - loss: 0.7004 - sparse_categorical_accuracy: 0.8040
Epoch 95/500
27/27 [==============================] - 0s 885us/step - loss: 0.7578 - sparse_categorical_accuracy: 0.7651
Epoch 96/500
27/27 [==============================] - 0s 903us/step - loss: 0.7159 - sparse_categorical_accuracy: 0.8005
Epoch 97/500
27/27 [==============================] - 0s 995us/step - loss: 0.6972 - sparse_categorical_accuracy: 0.8135
Epoch 98/500
27/27 [==============================] - 0s 906us/step - loss: 0.7073 - sparse_categorical_accuracy: 0.8087
Epoch 99/500
27/27 [==============================] - 0s 893us/step - loss: 0.7451 - sparse_categorical_accuracy: 0.7780
Epoch 100/500
27/27 [==============================] - 0s 5ms/step - loss: 0.6952 - sparse_categorical_accuracy: 0.8099 - val_loss: 0.9220 - val_sparse_categorical_accuracy: 0.7217
Epoch 101/500
27/27 [==============================] - 0s 869us/step - loss: 0.7454 - sparse_categorical_accuracy: 0.7863
Epoch 102/500
27/27 [==============================] - 0s 921us/step - loss: 0.7431 - sparse_categorical_accuracy: 0.7934
Epoch 103/500
27/27 [==============================] - 0s 934us/step - loss: 0.6931 - sparse_categorical_accuracy: 0.8005
Epoch 104/500
27/27 [==============================] - 0s 1ms/step - loss: 0.6887 - sparse_categorical_accuracy: 0.8064
Epoch 105/500
27/27 [==============================] - 0s 1ms/step - loss: 0.6730 - sparse_categorical_accuracy: 0.8170
Epoch 106/500
27/27 [==============================] - 0s 1ms/step - loss: 0.7147 - sparse_categorical_accuracy: 0.8040
Epoch 107/500
27/27 [==============================] - 0s 925us/step - loss: 0.7189 - sparse_categorical_accuracy: 0.7910
Epoch 108/500
27/27 [==============================] - 0s 963us/step - loss: 0.6830 - sparse_categorical_accuracy: 0.8111
Epoch 109/500
27/27 [==============================] - 0s 1ms/step - loss: 0.6995 - sparse_categorical_accuracy: 0.8158
Epoch 110/500
27/27 [==============================] - 0s 887us/step - loss: 0.6874 - sparse_categorical_accuracy: 0.8052
Epoch 111/500
27/27 [==============================] - 0s 921us/step - loss: 0.6595 - sparse_categorical_accuracy: 0.8276
Epoch 112/500
27/27 [==============================] - 0s 1ms/step - loss: 0.7001 - sparse_categorical_accuracy: 0.7910
Epoch 113/500
27/27 [==============================] - 0s 906us/step - loss: 0.6490 - sparse_categorical_accuracy: 0.8264
Epoch 114/500
27/27 [==============================] - 0s 829us/step - loss: 0.6860 - sparse_categorical_accuracy: 0.8076
Epoch 115/500
27/27 [==============================] - 0s 939us/step - loss: 0.6636 - sparse_categorical_accuracy: 0.8158
Epoch 116/500
27/27 [==============================] - 0s 917us/step - loss: 0.6662 - sparse_categorical_accuracy: 0.8241
Epoch 117/500
27/27 [==============================] - 0s 914us/step - loss: 0.6623 - sparse_categorical_accuracy: 0.8205
Epoch 118/500
27/27 [==============================] - 0s 881us/step - loss: 0.6576 - sparse_categorical_accuracy: 0.8276
Epoch 119/500
27/27 [==============================] - 0s 924us/step - loss: 0.6537 - sparse_categorical_accuracy: 0.8123
Epoch 120/500
27/27 [==============================] - 0s 911us/step - loss: 0.6368 - sparse_categorical_accuracy: 0.8264
Epoch 121/500
27/27 [==============================] - 0s 961us/step - loss: 0.6388 - sparse_categorical_accuracy: 0.8312
Epoch 122/500
27/27 [==============================] - 0s 946us/step - loss: 0.6272 - sparse_categorical_accuracy: 0.8229
Epoch 123/500
27/27 [==============================] - 0s 848us/step - loss: 0.6375 - sparse_categorical_accuracy: 0.8205
Epoch 124/500
27/27 [==============================] - 0s 924us/step - loss: 0.6118 - sparse_categorical_accuracy: 0.8430
Epoch 125/500
27/27 [==============================] - 0s 877us/step - loss: 0.6168 - sparse_categorical_accuracy: 0.8253
Epoch 126/500
27/27 [==============================] - 0s 921us/step - loss: 0.6371 - sparse_categorical_accuracy: 0.8264
Epoch 127/500
27/27 [==============================] - 0s 941us/step - loss: 0.6289 - sparse_categorical_accuracy: 0.8241
Epoch 128/500
27/27 [==============================] - 0s 897us/step - loss: 0.6146 - sparse_categorical_accuracy: 0.8288
Epoch 129/500
27/27 [==============================] - 0s 925us/step - loss: 0.6426 - sparse_categorical_accuracy: 0.8182
Epoch 130/500
27/27 [==============================] - 0s 922us/step - loss: 0.6036 - sparse_categorical_accuracy: 0.8654
Epoch 131/500
27/27 [==============================] - 0s 891us/step - loss: 0.6938 - sparse_categorical_accuracy: 0.8028
Epoch 132/500
27/27 [==============================] - 0s 930us/step - loss: 0.6204 - sparse_categorical_accuracy: 0.8548
Epoch 133/500
27/27 [==============================] - 0s 952us/step - loss: 0.6165 - sparse_categorical_accuracy: 0.8583
Epoch 134/500
27/27 [==============================] - 0s 877us/step - loss: 0.6194 - sparse_categorical_accuracy: 0.8524
Epoch 135/500
27/27 [==============================] - 0s 936us/step - loss: 0.6111 - sparse_categorical_accuracy: 0.8630
Epoch 136/500
27/27 [==============================] - 0s 829us/step - loss: 0.5766 - sparse_categorical_accuracy: 0.8855
Epoch 137/500
27/27 [==============================] - 0s 948us/step - loss: 0.5779 - sparse_categorical_accuracy: 0.8678
Epoch 138/500
27/27 [==============================] - 0s 828us/step - loss: 0.5750 - sparse_categorical_accuracy: 0.8819
Epoch 139/500
27/27 [==============================] - 0s 919us/step - loss: 0.5946 - sparse_categorical_accuracy: 0.8796
Epoch 140/500
27/27 [==============================] - 0s 919us/step - loss: 0.5693 - sparse_categorical_accuracy: 0.8890
Epoch 141/500
27/27 [==============================] - 0s 910us/step - loss: 0.5717 - sparse_categorical_accuracy: 0.8914
Epoch 142/500
27/27 [==============================] - 0s 966us/step - loss: 0.5723 - sparse_categorical_accuracy: 0.8878
Epoch 143/500
27/27 [==============================] - 0s 883us/step - loss: 0.5872 - sparse_categorical_accuracy: 0.8784
Epoch 144/500
27/27 [==============================] - 0s 846us/step - loss: 0.5940 - sparse_categorical_accuracy: 0.8725
Epoch 145/500
27/27 [==============================] - 0s 828us/step - loss: 0.5727 - sparse_categorical_accuracy: 0.8890
Epoch 146/500
27/27 [==============================] - 0s 861us/step - loss: 0.5764 - sparse_categorical_accuracy: 0.8878
Epoch 147/500
27/27 [==============================] - 0s 875us/step - loss: 0.5413 - sparse_categorical_accuracy: 0.9032
Epoch 148/500
27/27 [==============================] - 0s 832us/step - loss: 0.5615 - sparse_categorical_accuracy: 0.8855
Epoch 149/500
27/27 [==============================] - 0s 920us/step - loss: 0.5481 - sparse_categorical_accuracy: 0.9055
Epoch 150/500
27/27 [==============================] - 0s 961us/step - loss: 0.5751 - sparse_categorical_accuracy: 0.8914
Epoch 151/500
27/27 [==============================] - 0s 949us/step - loss: 0.5198 - sparse_categorical_accuracy: 0.9055
Epoch 152/500
27/27 [==============================] - 0s 909us/step - loss: 0.5125 - sparse_categorical_accuracy: 0.9126
Epoch 153/500
27/27 [==============================] - 0s 903us/step - loss: 0.5143 - sparse_categorical_accuracy: 0.9221
Epoch 154/500
27/27 [==============================] - 0s 906us/step - loss: 0.5842 - sparse_categorical_accuracy: 0.8678
Epoch 155/500
27/27 [==============================] - 0s 868us/step - loss: 0.5322 - sparse_categorical_accuracy: 0.9044
Epoch 156/500
27/27 [==============================] - 0s 832us/step - loss: 0.5105 - sparse_categorical_accuracy: 0.9162
Epoch 157/500
27/27 [==============================] - 0s 866us/step - loss: 0.5454 - sparse_categorical_accuracy: 0.8902
Epoch 158/500
27/27 [==============================] - 0s 1ms/step - loss: 0.5075 - sparse_categorical_accuracy: 0.9115
Epoch 159/500
27/27 [==============================] - 0s 966us/step - loss: 0.5293 - sparse_categorical_accuracy: 0.9032
Epoch 160/500
27/27 [==============================] - 0s 928us/step - loss: 0.5273 - sparse_categorical_accuracy: 0.9020
Epoch 161/500
27/27 [==============================] - 0s 860us/step - loss: 0.4955 - sparse_categorical_accuracy: 0.9174
Epoch 162/500
27/27 [==============================] - 0s 902us/step - loss: 0.4818 - sparse_categorical_accuracy: 0.9197
Epoch 163/500
27/27 [==============================] - 0s 847us/step - loss: 0.5052 - sparse_categorical_accuracy: 0.9020
Epoch 164/500
27/27 [==============================] - 0s 966us/step - loss: 0.5142 - sparse_categorical_accuracy: 0.9044
Epoch 165/500
27/27 [==============================] - 0s 849us/step - loss: 0.5139 - sparse_categorical_accuracy: 0.9126
Epoch 166/500
27/27 [==============================] - 0s 805us/step - loss: 0.5285 - sparse_categorical_accuracy: 0.8985
Epoch 167/500
27/27 [==============================] - 0s 879us/step - loss: 0.4723 - sparse_categorical_accuracy: 0.9268
Epoch 168/500
27/27 [==============================] - 0s 917us/step - loss: 0.4844 - sparse_categorical_accuracy: 0.9067
Epoch 169/500
27/27 [==============================] - 0s 886us/step - loss: 0.4956 - sparse_categorical_accuracy: 0.9103
Epoch 170/500
27/27 [==============================] - 0s 926us/step - loss: 0.4799 - sparse_categorical_accuracy: 0.9138
Epoch 171/500
27/27 [==============================] - 0s 949us/step - loss: 0.5113 - sparse_categorical_accuracy: 0.9079
Epoch 172/500
27/27 [==============================] - 0s 858us/step - loss: 0.4909 - sparse_categorical_accuracy: 0.9067
Epoch 173/500
27/27 [==============================] - 0s 908us/step - loss: 0.4714 - sparse_categorical_accuracy: 0.9103
Epoch 174/500
27/27 [==============================] - 0s 905us/step - loss: 0.4913 - sparse_categorical_accuracy: 0.9138
Epoch 175/500
27/27 [==============================] - 0s 838us/step - loss: 0.4989 - sparse_categorical_accuracy: 0.9103
Epoch 176/500
27/27 [==============================] - 0s 901us/step - loss: 0.4738 - sparse_categorical_accuracy: 0.9221
Epoch 177/500
27/27 [==============================] - 0s 884us/step - loss: 0.4929 - sparse_categorical_accuracy: 0.9032
Epoch 178/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4433 - sparse_categorical_accuracy: 0.9303
Epoch 179/500
27/27 [==============================] - 0s 901us/step - loss: 0.4551 - sparse_categorical_accuracy: 0.9303
Epoch 180/500
27/27 [==============================] - 0s 870us/step - loss: 0.4909 - sparse_categorical_accuracy: 0.9020
Epoch 181/500
27/27 [==============================] - 0s 924us/step - loss: 0.4522 - sparse_categorical_accuracy: 0.9185
Epoch 182/500
27/27 [==============================] - 0s 893us/step - loss: 0.4479 - sparse_categorical_accuracy: 0.9303
Epoch 183/500
27/27 [==============================] - 0s 904us/step - loss: 0.4413 - sparse_categorical_accuracy: 0.9256
Epoch 184/500
27/27 [==============================] - 0s 899us/step - loss: 0.4498 - sparse_categorical_accuracy: 0.9174
Epoch 185/500
27/27 [==============================] - 0s 843us/step - loss: 0.4517 - sparse_categorical_accuracy: 0.9162
Epoch 186/500
27/27 [==============================] - 0s 931us/step - loss: 0.4478 - sparse_categorical_accuracy: 0.9292
Epoch 187/500
27/27 [==============================] - 0s 846us/step - loss: 0.4498 - sparse_categorical_accuracy: 0.9138
Epoch 188/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4591 - sparse_categorical_accuracy: 0.9162
Epoch 189/500
27/27 [==============================] - 0s 878us/step - loss: 0.4742 - sparse_categorical_accuracy: 0.9044
Epoch 190/500
27/27 [==============================] - 0s 894us/step - loss: 0.4385 - sparse_categorical_accuracy: 0.9315
Epoch 191/500
27/27 [==============================] - 0s 920us/step - loss: 0.4501 - sparse_categorical_accuracy: 0.9280
Epoch 192/500
27/27 [==============================] - 0s 788us/step - loss: 0.4786 - sparse_categorical_accuracy: 0.9115
Epoch 193/500
27/27 [==============================] - 0s 932us/step - loss: 0.8577 - sparse_categorical_accuracy: 0.7568
Epoch 194/500
27/27 [==============================] - 0s 819us/step - loss: 0.7656 - sparse_categorical_accuracy: 0.7839
Epoch 195/500
27/27 [==============================] - 0s 957us/step - loss: 0.6410 - sparse_categorical_accuracy: 0.8453
Epoch 196/500
27/27 [==============================] - 0s 915us/step - loss: 0.6841 - sparse_categorical_accuracy: 0.8241
Epoch 197/500
27/27 [==============================] - 0s 876us/step - loss: 0.6684 - sparse_categorical_accuracy: 0.8241
Epoch 198/500
27/27 [==============================] - 0s 953us/step - loss: 0.6583 - sparse_categorical_accuracy: 0.8312
Epoch 199/500
27/27 [==============================] - 0s 826us/step - loss: 0.5459 - sparse_categorical_accuracy: 0.8843
Epoch 200/500
27/27 [==============================] - 0s 2ms/step - loss: 0.5818 - sparse_categorical_accuracy: 0.8843 - val_loss: 0.6180 - val_sparse_categorical_accuracy: 0.8302
Epoch 201/500
27/27 [==============================] - 0s 889us/step - loss: 0.5705 - sparse_categorical_accuracy: 0.8843
Epoch 202/500
27/27 [==============================] - 0s 872us/step - loss: 0.6053 - sparse_categorical_accuracy: 0.8548
Epoch 203/500
27/27 [==============================] - 0s 916us/step - loss: 0.6325 - sparse_categorical_accuracy: 0.8442
Epoch 204/500
27/27 [==============================] - 0s 828us/step - loss: 0.5133 - sparse_categorical_accuracy: 0.9008
Epoch 205/500
27/27 [==============================] - 0s 954us/step - loss: 0.6436 - sparse_categorical_accuracy: 0.8501
Epoch 206/500
27/27 [==============================] - 0s 878us/step - loss: 0.4927 - sparse_categorical_accuracy: 0.9268
Epoch 207/500
27/27 [==============================] - 0s 994us/step - loss: 0.4982 - sparse_categorical_accuracy: 0.9126
Epoch 208/500
27/27 [==============================] - 0s 860us/step - loss: 0.5219 - sparse_categorical_accuracy: 0.9044
Epoch 209/500
27/27 [==============================] - 0s 894us/step - loss: 0.5310 - sparse_categorical_accuracy: 0.8996
Epoch 210/500
27/27 [==============================] - 0s 884us/step - loss: 0.5166 - sparse_categorical_accuracy: 0.9103
Epoch 211/500
27/27 [==============================] - 0s 922us/step - loss: 0.5291 - sparse_categorical_accuracy: 0.8843
Epoch 212/500
27/27 [==============================] - 0s 974us/step - loss: 0.4659 - sparse_categorical_accuracy: 0.9221
Epoch 213/500
27/27 [==============================] - 0s 887us/step - loss: 0.4971 - sparse_categorical_accuracy: 0.9209
Epoch 214/500
27/27 [==============================] - 0s 958us/step - loss: 0.4663 - sparse_categorical_accuracy: 0.9351
Epoch 215/500
27/27 [==============================] - 0s 852us/step - loss: 0.4781 - sparse_categorical_accuracy: 0.9091
Epoch 216/500
27/27 [==============================] - 0s 854us/step - loss: 0.8753 - sparse_categorical_accuracy: 0.7710
Epoch 217/500
27/27 [==============================] - 0s 921us/step - loss: 0.6263 - sparse_categorical_accuracy: 0.8465
Epoch 218/500
27/27 [==============================] - 0s 846us/step - loss: 0.5606 - sparse_categorical_accuracy: 0.8926
Epoch 219/500
27/27 [==============================] - 0s 970us/step - loss: 0.5323 - sparse_categorical_accuracy: 0.9020
Epoch 220/500
27/27 [==============================] - 0s 911us/step - loss: 0.5313 - sparse_categorical_accuracy: 0.9162
Epoch 221/500
27/27 [==============================] - 0s 898us/step - loss: 0.5543 - sparse_categorical_accuracy: 0.8949
Epoch 222/500
27/27 [==============================] - 0s 900us/step - loss: 0.5170 - sparse_categorical_accuracy: 0.9138
Epoch 223/500
27/27 [==============================] - 0s 891us/step - loss: 0.5134 - sparse_categorical_accuracy: 0.9091
Epoch 224/500
27/27 [==============================] - 0s 969us/step - loss: 0.4835 - sparse_categorical_accuracy: 0.9303
Epoch 225/500
27/27 [==============================] - 0s 915us/step - loss: 0.5224 - sparse_categorical_accuracy: 0.9150
Epoch 226/500
27/27 [==============================] - 0s 946us/step - loss: 0.5245 - sparse_categorical_accuracy: 0.9115
Epoch 227/500
27/27 [==============================] - 0s 903us/step - loss: 0.4805 - sparse_categorical_accuracy: 0.9256
Epoch 228/500
27/27 [==============================] - 0s 883us/step - loss: 0.4679 - sparse_categorical_accuracy: 0.9445
Epoch 229/500
27/27 [==============================] - 0s 922us/step - loss: 0.4859 - sparse_categorical_accuracy: 0.9150
Epoch 230/500
27/27 [==============================] - 0s 872us/step - loss: 0.4979 - sparse_categorical_accuracy: 0.9280
Epoch 231/500
27/27 [==============================] - 0s 829us/step - loss: 0.5351 - sparse_categorical_accuracy: 0.8949
Epoch 232/500
27/27 [==============================] - 0s 849us/step - loss: 0.4932 - sparse_categorical_accuracy: 0.9150
Epoch 233/500
27/27 [==============================] - 0s 905us/step - loss: 0.4898 - sparse_categorical_accuracy: 0.9221
Epoch 234/500
27/27 [==============================] - 0s 897us/step - loss: 0.4663 - sparse_categorical_accuracy: 0.9292
Epoch 235/500
27/27 [==============================] - 0s 815us/step - loss: 0.4764 - sparse_categorical_accuracy: 0.9315
Epoch 236/500
27/27 [==============================] - 0s 891us/step - loss: 0.4716 - sparse_categorical_accuracy: 0.9268
Epoch 237/500
27/27 [==============================] - 0s 851us/step - loss: 0.4625 - sparse_categorical_accuracy: 0.9280
Epoch 238/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4851 - sparse_categorical_accuracy: 0.9150
Epoch 239/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4528 - sparse_categorical_accuracy: 0.9421
Epoch 240/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4559 - sparse_categorical_accuracy: 0.9351
Epoch 241/500
27/27 [==============================] - 0s 956us/step - loss: 0.4689 - sparse_categorical_accuracy: 0.9256
Epoch 242/500
27/27 [==============================] - 0s 914us/step - loss: 0.4644 - sparse_categorical_accuracy: 0.9185
Epoch 243/500
27/27 [==============================] - 0s 978us/step - loss: 0.4662 - sparse_categorical_accuracy: 0.9268
Epoch 244/500
27/27 [==============================] - 0s 922us/step - loss: 0.4631 - sparse_categorical_accuracy: 0.9327
Epoch 245/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4798 - sparse_categorical_accuracy: 0.9174
Epoch 246/500
27/27 [==============================] - 0s 894us/step - loss: 0.4831 - sparse_categorical_accuracy: 0.9115
Epoch 247/500
27/27 [==============================] - 0s 866us/step - loss: 0.4492 - sparse_categorical_accuracy: 0.9303
Epoch 248/500
27/27 [==============================] - 0s 891us/step - loss: 0.4465 - sparse_categorical_accuracy: 0.9221
Epoch 249/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4688 - sparse_categorical_accuracy: 0.9185
Epoch 250/500
27/27 [==============================] - 0s 922us/step - loss: 0.4528 - sparse_categorical_accuracy: 0.9115
Epoch 251/500
27/27 [==============================] - 0s 870us/step - loss: 0.4545 - sparse_categorical_accuracy: 0.9233
Epoch 252/500
27/27 [==============================] - 0s 912us/step - loss: 0.4520 - sparse_categorical_accuracy: 0.9209
Epoch 253/500
27/27 [==============================] - 0s 921us/step - loss: 0.4407 - sparse_categorical_accuracy: 0.9244
Epoch 254/500
27/27 [==============================] - 0s 882us/step - loss: 0.4642 - sparse_categorical_accuracy: 0.9162
Epoch 255/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4712 - sparse_categorical_accuracy: 0.9197
Epoch 256/500
27/27 [==============================] - 0s 920us/step - loss: 0.4355 - sparse_categorical_accuracy: 0.9292
Epoch 257/500
27/27 [==============================] - 0s 896us/step - loss: 0.4480 - sparse_categorical_accuracy: 0.9280
Epoch 258/500
27/27 [==============================] - 0s 894us/step - loss: 0.4551 - sparse_categorical_accuracy: 0.9185
Epoch 259/500
27/27 [==============================] - 0s 930us/step - loss: 0.4265 - sparse_categorical_accuracy: 0.9303
Epoch 260/500
27/27 [==============================] - 0s 955us/step - loss: 0.4351 - sparse_categorical_accuracy: 0.9303
Epoch 261/500
27/27 [==============================] - 0s 907us/step - loss: 0.4446 - sparse_categorical_accuracy: 0.9185
Epoch 262/500
27/27 [==============================] - 0s 921us/step - loss: 0.4341 - sparse_categorical_accuracy: 0.9185
Epoch 263/500
27/27 [==============================] - 0s 902us/step - loss: 0.4323 - sparse_categorical_accuracy: 0.9244
Epoch 264/500
27/27 [==============================] - 0s 880us/step - loss: 0.4646 - sparse_categorical_accuracy: 0.9126
Epoch 265/500
27/27 [==============================] - 0s 934us/step - loss: 0.4455 - sparse_categorical_accuracy: 0.9268
Epoch 266/500
27/27 [==============================] - 0s 999us/step - loss: 0.4367 - sparse_categorical_accuracy: 0.9315
Epoch 267/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4499 - sparse_categorical_accuracy: 0.9221
Epoch 268/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4370 - sparse_categorical_accuracy: 0.9268
Epoch 269/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4514 - sparse_categorical_accuracy: 0.9185
Epoch 270/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4524 - sparse_categorical_accuracy: 0.9197
Epoch 271/500
27/27 [==============================] - 0s 964us/step - loss: 0.4208 - sparse_categorical_accuracy: 0.9197
Epoch 272/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4359 - sparse_categorical_accuracy: 0.9221
Epoch 273/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4430 - sparse_categorical_accuracy: 0.9091
Epoch 274/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4331 - sparse_categorical_accuracy: 0.9292
Epoch 275/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4371 - sparse_categorical_accuracy: 0.9303
Epoch 276/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4251 - sparse_categorical_accuracy: 0.9292
Epoch 277/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4709 - sparse_categorical_accuracy: 0.9091
Epoch 278/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4422 - sparse_categorical_accuracy: 0.9233
Epoch 279/500
27/27 [==============================] - 0s 939us/step - loss: 0.4343 - sparse_categorical_accuracy: 0.9233
Epoch 280/500
27/27 [==============================] - 0s 983us/step - loss: 0.4235 - sparse_categorical_accuracy: 0.9174
Epoch 281/500
27/27 [==============================] - 0s 998us/step - loss: 0.4172 - sparse_categorical_accuracy: 0.9209
Epoch 282/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4209 - sparse_categorical_accuracy: 0.9327
Epoch 283/500
27/27 [==============================] - 0s 889us/step - loss: 0.4193 - sparse_categorical_accuracy: 0.9327
Epoch 284/500
27/27 [==============================] - 0s 966us/step - loss: 0.4276 - sparse_categorical_accuracy: 0.9315
Epoch 285/500
27/27 [==============================] - 0s 957us/step - loss: 0.4333 - sparse_categorical_accuracy: 0.9185
Epoch 286/500
27/27 [==============================] - 0s 959us/step - loss: 0.4231 - sparse_categorical_accuracy: 0.9280
Epoch 287/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4238 - sparse_categorical_accuracy: 0.9303
Epoch 288/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4168 - sparse_categorical_accuracy: 0.9327
Epoch 289/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4387 - sparse_categorical_accuracy: 0.9256
Epoch 290/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4315 - sparse_categorical_accuracy: 0.9197
Epoch 291/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4421 - sparse_categorical_accuracy: 0.9174
Epoch 292/500
27/27 [==============================] - 0s 997us/step - loss: 0.4468 - sparse_categorical_accuracy: 0.9185
Epoch 293/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4290 - sparse_categorical_accuracy: 0.9244
Epoch 294/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4279 - sparse_categorical_accuracy: 0.9292
Epoch 295/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4298 - sparse_categorical_accuracy: 0.9197
Epoch 296/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4276 - sparse_categorical_accuracy: 0.9256
Epoch 297/500
27/27 [==============================] - 0s 984us/step - loss: 0.4504 - sparse_categorical_accuracy: 0.9126
Epoch 298/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4267 - sparse_categorical_accuracy: 0.9268
Epoch 299/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4237 - sparse_categorical_accuracy: 0.9268
Epoch 300/500
27/27 [==============================] - 0s 2ms/step - loss: 0.4234 - sparse_categorical_accuracy: 0.9197 - val_loss: 0.4862 - val_sparse_categorical_accuracy: 0.9009
Epoch 301/500
27/27 [==============================] - 0s 942us/step - loss: 0.4251 - sparse_categorical_accuracy: 0.9280
Epoch 302/500
27/27 [==============================] - 0s 815us/step - loss: 0.4145 - sparse_categorical_accuracy: 0.9280
Epoch 303/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4209 - sparse_categorical_accuracy: 0.9256
Epoch 304/500
27/27 [==============================] - 0s 941us/step - loss: 0.4181 - sparse_categorical_accuracy: 0.9339
Epoch 305/500
27/27 [==============================] - 0s 913us/step - loss: 0.4181 - sparse_categorical_accuracy: 0.9292
Epoch 306/500
27/27 [==============================] - 0s 936us/step - loss: 0.4263 - sparse_categorical_accuracy: 0.9221
Epoch 307/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4386 - sparse_categorical_accuracy: 0.9221
Epoch 308/500
27/27 [==============================] - 0s 927us/step - loss: 0.4195 - sparse_categorical_accuracy: 0.9327
Epoch 309/500
27/27 [==============================] - 0s 991us/step - loss: 0.4153 - sparse_categorical_accuracy: 0.9233
Epoch 310/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4197 - sparse_categorical_accuracy: 0.9268
Epoch 311/500
27/27 [==============================] - 0s 987us/step - loss: 0.4112 - sparse_categorical_accuracy: 0.9280
Epoch 312/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4134 - sparse_categorical_accuracy: 0.9244
Epoch 313/500
27/27 [==============================] - 0s 943us/step - loss: 0.4155 - sparse_categorical_accuracy: 0.9303
Epoch 314/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4146 - sparse_categorical_accuracy: 0.9280
Epoch 315/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4296 - sparse_categorical_accuracy: 0.9209
Epoch 316/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4223 - sparse_categorical_accuracy: 0.9256
Epoch 317/500
27/27 [==============================] - 0s 919us/step - loss: 0.4143 - sparse_categorical_accuracy: 0.9233
Epoch 318/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4137 - sparse_categorical_accuracy: 0.9256
Epoch 319/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4136 - sparse_categorical_accuracy: 0.9221
Epoch 320/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4236 - sparse_categorical_accuracy: 0.9209
Epoch 321/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4189 - sparse_categorical_accuracy: 0.9162
Epoch 322/500
27/27 [==============================] - 0s 966us/step - loss: 0.4292 - sparse_categorical_accuracy: 0.9244
Epoch 323/500
27/27 [==============================] - 0s 900us/step - loss: 0.4261 - sparse_categorical_accuracy: 0.9126
Epoch 324/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3953 - sparse_categorical_accuracy: 0.9315
Epoch 325/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4123 - sparse_categorical_accuracy: 0.9256
Epoch 326/500
27/27 [==============================] - 0s 921us/step - loss: 0.4052 - sparse_categorical_accuracy: 0.9327
Epoch 327/500
27/27 [==============================] - 0s 951us/step - loss: 0.3970 - sparse_categorical_accuracy: 0.9256
Epoch 328/500
27/27 [==============================] - 0s 992us/step - loss: 0.4007 - sparse_categorical_accuracy: 0.9339
Epoch 329/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4056 - sparse_categorical_accuracy: 0.9174
Epoch 330/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3985 - sparse_categorical_accuracy: 0.9315
Epoch 331/500
27/27 [==============================] - 0s 924us/step - loss: 0.3995 - sparse_categorical_accuracy: 0.9303
Epoch 332/500
27/27 [==============================] - 0s 951us/step - loss: 0.4010 - sparse_categorical_accuracy: 0.9256
Epoch 333/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4118 - sparse_categorical_accuracy: 0.9174
Epoch 334/500
27/27 [==============================] - 0s 994us/step - loss: 0.4047 - sparse_categorical_accuracy: 0.9268
Epoch 335/500
27/27 [==============================] - 0s 968us/step - loss: 0.3990 - sparse_categorical_accuracy: 0.9268
Epoch 336/500
27/27 [==============================] - 0s 992us/step - loss: 0.4063 - sparse_categorical_accuracy: 0.9221
Epoch 337/500
27/27 [==============================] - 0s 994us/step - loss: 0.3987 - sparse_categorical_accuracy: 0.9362
Epoch 338/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3977 - sparse_categorical_accuracy: 0.9339
Epoch 339/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4041 - sparse_categorical_accuracy: 0.9244
Epoch 340/500
27/27 [==============================] - 0s 987us/step - loss: 0.3989 - sparse_categorical_accuracy: 0.9280
Epoch 341/500
27/27 [==============================] - 0s 890us/step - loss: 0.3923 - sparse_categorical_accuracy: 0.9315
Epoch 342/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4158 - sparse_categorical_accuracy: 0.9221
Epoch 343/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4068 - sparse_categorical_accuracy: 0.9244
Epoch 344/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3938 - sparse_categorical_accuracy: 0.9268
Epoch 345/500
27/27 [==============================] - 0s 918us/step - loss: 0.3955 - sparse_categorical_accuracy: 0.9221
Epoch 346/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3933 - sparse_categorical_accuracy: 0.9339
Epoch 347/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3979 - sparse_categorical_accuracy: 0.9292
Epoch 348/500
27/27 [==============================] - 0s 964us/step - loss: 0.4074 - sparse_categorical_accuracy: 0.9303
Epoch 349/500
27/27 [==============================] - 0s 916us/step - loss: 0.4044 - sparse_categorical_accuracy: 0.9268
Epoch 350/500
27/27 [==============================] - 0s 953us/step - loss: 0.3896 - sparse_categorical_accuracy: 0.9445
Epoch 351/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3912 - sparse_categorical_accuracy: 0.9268
Epoch 352/500
27/27 [==============================] - 0s 995us/step - loss: 0.4089 - sparse_categorical_accuracy: 0.9174
Epoch 353/500
27/27 [==============================] - 0s 919us/step - loss: 0.3987 - sparse_categorical_accuracy: 0.9292
Epoch 354/500
27/27 [==============================] - 0s 992us/step - loss: 0.4009 - sparse_categorical_accuracy: 0.9256
Epoch 355/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4162 - sparse_categorical_accuracy: 0.9055
Epoch 356/500
27/27 [==============================] - 0s 960us/step - loss: 0.4001 - sparse_categorical_accuracy: 0.9280
Epoch 357/500
27/27 [==============================] - 0s 854us/step - loss: 0.4024 - sparse_categorical_accuracy: 0.9244
Epoch 358/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4005 - sparse_categorical_accuracy: 0.9339
Epoch 359/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4022 - sparse_categorical_accuracy: 0.9280
Epoch 360/500
27/27 [==============================] - 0s 960us/step - loss: 0.3940 - sparse_categorical_accuracy: 0.9221
Epoch 361/500
27/27 [==============================] - 0s 913us/step - loss: 0.3889 - sparse_categorical_accuracy: 0.9315
Epoch 362/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4115 - sparse_categorical_accuracy: 0.9197
Epoch 363/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3932 - sparse_categorical_accuracy: 0.9280
Epoch 364/500
27/27 [==============================] - 0s 895us/step - loss: 0.4010 - sparse_categorical_accuracy: 0.9268
Epoch 365/500
27/27 [==============================] - 0s 842us/step - loss: 0.3948 - sparse_categorical_accuracy: 0.9433
Epoch 366/500
27/27 [==============================] - 0s 961us/step - loss: 0.4089 - sparse_categorical_accuracy: 0.9303
Epoch 367/500
27/27 [==============================] - 0s 916us/step - loss: 0.4158 - sparse_categorical_accuracy: 0.9233
Epoch 368/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4151 - sparse_categorical_accuracy: 0.9233
Epoch 369/500
27/27 [==============================] - 0s 997us/step - loss: 0.3966 - sparse_categorical_accuracy: 0.9303
Epoch 370/500
27/27 [==============================] - 0s 987us/step - loss: 0.3907 - sparse_categorical_accuracy: 0.9280
Epoch 371/500
27/27 [==============================] - 0s 876us/step - loss: 0.3963 - sparse_categorical_accuracy: 0.9280
Epoch 372/500
27/27 [==============================] - 0s 950us/step - loss: 0.4117 - sparse_categorical_accuracy: 0.9162
Epoch 373/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3875 - sparse_categorical_accuracy: 0.9327
Epoch 374/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3900 - sparse_categorical_accuracy: 0.9256
Epoch 375/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3902 - sparse_categorical_accuracy: 0.9362
Epoch 376/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3970 - sparse_categorical_accuracy: 0.9292
Epoch 377/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3947 - sparse_categorical_accuracy: 0.9327
Epoch 378/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4000 - sparse_categorical_accuracy: 0.9280
Epoch 379/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3951 - sparse_categorical_accuracy: 0.9327
Epoch 380/500
27/27 [==============================] - 0s 998us/step - loss: 0.4030 - sparse_categorical_accuracy: 0.9162
Epoch 381/500
27/27 [==============================] - 0s 933us/step - loss: 0.3934 - sparse_categorical_accuracy: 0.9339
Epoch 382/500
27/27 [==============================] - 0s 976us/step - loss: 0.4039 - sparse_categorical_accuracy: 0.9174
Epoch 383/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3963 - sparse_categorical_accuracy: 0.9292
Epoch 384/500
27/27 [==============================] - 0s 892us/step - loss: 0.3821 - sparse_categorical_accuracy: 0.9303
Epoch 385/500
27/27 [==============================] - 0s 870us/step - loss: 0.3921 - sparse_categorical_accuracy: 0.9339
Epoch 386/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3856 - sparse_categorical_accuracy: 0.9327
Epoch 387/500
27/27 [==============================] - 0s 955us/step - loss: 0.4011 - sparse_categorical_accuracy: 0.9256
Epoch 388/500
27/27 [==============================] - 0s 1ms/step - loss: 0.4020 - sparse_categorical_accuracy: 0.9268
Epoch 389/500
27/27 [==============================] - 0s 972us/step - loss: 0.4067 - sparse_categorical_accuracy: 0.9174
Epoch 390/500
27/27 [==============================] - 0s 947us/step - loss: 0.3943 - sparse_categorical_accuracy: 0.9303
Epoch 391/500
27/27 [==============================] - 0s 900us/step - loss: 0.3964 - sparse_categorical_accuracy: 0.9315
Epoch 392/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3911 - sparse_categorical_accuracy: 0.9374
Epoch 393/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3944 - sparse_categorical_accuracy: 0.9327
Epoch 394/500
27/27 [==============================] - 0s 861us/step - loss: 0.3830 - sparse_categorical_accuracy: 0.9268
Epoch 395/500
27/27 [==============================] - 0s 861us/step - loss: 0.3900 - sparse_categorical_accuracy: 0.9268
Epoch 396/500
27/27 [==============================] - 0s 956us/step - loss: 0.3933 - sparse_categorical_accuracy: 0.9386
Epoch 397/500
27/27 [==============================] - 0s 861us/step - loss: 0.3882 - sparse_categorical_accuracy: 0.9197
Epoch 398/500
27/27 [==============================] - 0s 981us/step - loss: 0.3919 - sparse_categorical_accuracy: 0.9292
Epoch 399/500
27/27 [==============================] - 0s 956us/step - loss: 0.3855 - sparse_categorical_accuracy: 0.9445
Epoch 400/500
27/27 [==============================] - 0s 2ms/step - loss: 0.3949 - sparse_categorical_accuracy: 0.9339 - val_loss: 0.4553 - val_sparse_categorical_accuracy: 0.9009
Epoch 401/500
27/27 [==============================] - 0s 976us/step - loss: 0.3855 - sparse_categorical_accuracy: 0.9327
Epoch 402/500
27/27 [==============================] - 0s 962us/step - loss: 0.3859 - sparse_categorical_accuracy: 0.9327
Epoch 403/500
27/27 [==============================] - 0s 999us/step - loss: 0.3948 - sparse_categorical_accuracy: 0.9292
Epoch 404/500
27/27 [==============================] - 0s 988us/step - loss: 0.3889 - sparse_categorical_accuracy: 0.9339
Epoch 405/500
27/27 [==============================] - 0s 986us/step - loss: 0.3880 - sparse_categorical_accuracy: 0.9268
Epoch 406/500
27/27 [==============================] - 0s 850us/step - loss: 0.4030 - sparse_categorical_accuracy: 0.9303
Epoch 407/500
27/27 [==============================] - 0s 873us/step - loss: 0.4043 - sparse_categorical_accuracy: 0.9162
Epoch 408/500
27/27 [==============================] - 0s 868us/step - loss: 0.3899 - sparse_categorical_accuracy: 0.9292
Epoch 409/500
27/27 [==============================] - 0s 853us/step - loss: 0.3889 - sparse_categorical_accuracy: 0.9351
Epoch 410/500
27/27 [==============================] - 0s 944us/step - loss: 0.3900 - sparse_categorical_accuracy: 0.9315
Epoch 411/500
27/27 [==============================] - 0s 947us/step - loss: 0.3880 - sparse_categorical_accuracy: 0.9292
Epoch 412/500
27/27 [==============================] - 0s 902us/step - loss: 0.3998 - sparse_categorical_accuracy: 0.9233
Epoch 413/500
27/27 [==============================] - 0s 867us/step - loss: 0.4004 - sparse_categorical_accuracy: 0.9209
Epoch 414/500
27/27 [==============================] - 0s 1ms/step - loss: 0.3790 - sparse_categorical_accuracy: 0.9386
Epoch 415/500
27/27 [==============================] - 0s 846us/step - loss: 0.3935 - sparse_categorical_accuracy: 0.9339
Epoch 416/500
27/27 [==============================] - 0s 922us/step - loss: 0.3920 - sparse_categorical_accuracy: 0.9256
Epoch 417/500
27/27 [==============================] - 0s 908us/step - loss: 0.4027 - sparse_categorical_accuracy: 0.9221
Epoch 418/500
27/27 [==============================] - 0s 896us/step - loss: 0.3829 - sparse_categorical_accuracy: 0.9315
Epoch 419/500
27/27 [==============================] - 0s 871us/step - loss: 0.3883 - sparse_categorical_accuracy: 0.9303
Epoch 420/500
27/27 [==============================] - 0s 899us/step - loss: 0.3951 - sparse_categorical_accuracy: 0.9244
Epoch 421/500
27/27 [==============================] - 0s 954us/step - loss: 0.3848 - sparse_categorical_accuracy: 0.9244
Epoch 422/500
27/27 [==============================] - 0s 849us/step - loss: 0.3833 - sparse_categorical_accuracy: 0.9327
Epoch 423/500
27/27 [==============================] - 0s 970us/step - loss: 0.3908 - sparse_categorical_accuracy: 0.9327
Epoch 424/500
27/27 [==============================] - 0s 882us/step - loss: 0.3799 - sparse_categorical_accuracy: 0.9398
Epoch 425/500
27/27 [==============================] - 0s 925us/step - loss: 0.3862 - sparse_categorical_accuracy: 0.9280
Epoch 426/500
27/27 [==============================] - 0s 908us/step - loss: 0.3862 - sparse_categorical_accuracy: 0.9362
Epoch 427/500
27/27 [==============================] - 0s 905us/step - loss: 0.3902 - sparse_categorical_accuracy: 0.9362
Epoch 428/500
27/27 [==============================] - 0s 943us/step - loss: 0.3926 - sparse_categorical_accuracy: 0.9327
Epoch 429/500
27/27 [==============================] - 0s 858us/step - loss: 0.3928 - sparse_categorical_accuracy: 0.9292
Epoch 430/500
27/27 [==============================] - 0s 923us/step - loss: 0.3794 - sparse_categorical_accuracy: 0.9362
Epoch 431/500
27/27 [==============================] - 0s 909us/step - loss: 0.4107 - sparse_categorical_accuracy: 0.9174
Epoch 432/500
27/27 [==============================] - 0s 921us/step - loss: 0.3922 - sparse_categorical_accuracy: 0.9303
Epoch 433/500
27/27 [==============================] - 0s 897us/step - loss: 0.3915 - sparse_categorical_accuracy: 0.9244
Epoch 434/500
27/27 [==============================] - 0s 890us/step - loss: 0.3866 - sparse_categorical_accuracy: 0.9327
Epoch 435/500
27/27 [==============================] - 0s 935us/step - loss: 0.3959 - sparse_categorical_accuracy: 0.9256
Epoch 436/500
27/27 [==============================] - 0s 881us/step - loss: 0.3969 - sparse_categorical_accuracy: 0.9268
Epoch 437/500
27/27 [==============================] - 0s 923us/step - loss: 0.4027 - sparse_categorical_accuracy: 0.9256
Epoch 438/500
27/27 [==============================] - 0s 936us/step - loss: 0.3999 - sparse_categorical_accuracy: 0.9315
Epoch 439/500
27/27 [==============================] - 0s 864us/step - loss: 0.3844 - sparse_categorical_accuracy: 0.9280
Epoch 440/500
27/27 [==============================] - 0s 894us/step - loss: 0.3873 - sparse_categorical_accuracy: 0.9268
Epoch 441/500
27/27 [==============================] - 0s 891us/step - loss: 0.3905 - sparse_categorical_accuracy: 0.9197
Epoch 442/500
27/27 [==============================] - 0s 903us/step - loss: 0.3849 - sparse_categorical_accuracy: 0.9386
Epoch 443/500
27/27 [==============================] - 0s 859us/step - loss: 0.3955 - sparse_categorical_accuracy: 0.9256
Epoch 444/500
27/27 [==============================] - 0s 879us/step - loss: 0.4151 - sparse_categorical_accuracy: 0.9091
Epoch 445/500
27/27 [==============================] - 0s 942us/step - loss: 0.4156 - sparse_categorical_accuracy: 0.9162
Epoch 446/500
27/27 [==============================] - 0s 928us/step - loss: 0.3875 - sparse_categorical_accuracy: 0.9315
Epoch 447/500
27/27 [==============================] - 0s 934us/step - loss: 0.4006 - sparse_categorical_accuracy: 0.9197
Epoch 448/500
27/27 [==============================] - 0s 928us/step - loss: 0.4075 - sparse_categorical_accuracy: 0.9126
Epoch 449/500
27/27 [==============================] - 0s 905us/step - loss: 0.3885 - sparse_categorical_accuracy: 0.9362
Epoch 450/500
27/27 [==============================] - 0s 937us/step - loss: 0.3912 - sparse_categorical_accuracy: 0.9233
Epoch 451/500
27/27 [==============================] - 0s 893us/step - loss: 0.3936 - sparse_categorical_accuracy: 0.9150
Epoch 452/500
27/27 [==============================] - 0s 909us/step - loss: 0.3911 - sparse_categorical_accuracy: 0.9303
Epoch 453/500
27/27 [==============================] - 0s 876us/step - loss: 0.3863 - sparse_categorical_accuracy: 0.9244
Epoch 454/500
27/27 [==============================] - 0s 910us/step - loss: 0.3830 - sparse_categorical_accuracy: 0.9268
Epoch 455/500
27/27 [==============================] - 0s 882us/step - loss: 0.3855 - sparse_categorical_accuracy: 0.9268
Epoch 456/500
27/27 [==============================] - 0s 896us/step - loss: 0.3845 - sparse_categorical_accuracy: 0.9280
Epoch 457/500
27/27 [==============================] - 0s 952us/step - loss: 0.3821 - sparse_categorical_accuracy: 0.9256
Epoch 458/500
27/27 [==============================] - 0s 891us/step - loss: 0.3823 - sparse_categorical_accuracy: 0.9292
Epoch 459/500
27/27 [==============================] - 0s 832us/step - loss: 0.3910 - sparse_categorical_accuracy: 0.9256
Epoch 460/500
27/27 [==============================] - 0s 905us/step - loss: 0.3842 - sparse_categorical_accuracy: 0.9315
Epoch 461/500
27/27 [==============================] - 0s 858us/step - loss: 0.3790 - sparse_categorical_accuracy: 0.9292
Epoch 462/500
27/27 [==============================] - 0s 856us/step - loss: 0.3917 - sparse_categorical_accuracy: 0.9162
Epoch 463/500
27/27 [==============================] - 0s 868us/step - loss: 0.3878 - sparse_categorical_accuracy: 0.9292
Epoch 464/500
27/27 [==============================] - 0s 901us/step - loss: 0.3862 - sparse_categorical_accuracy: 0.9339
Epoch 465/500
27/27 [==============================] - 0s 856us/step - loss: 0.3827 - sparse_categorical_accuracy: 0.9374
Epoch 466/500
27/27 [==============================] - 0s 931us/step - loss: 0.3956 - sparse_categorical_accuracy: 0.9221
Epoch 467/500
27/27 [==============================] - 0s 859us/step - loss: 0.3917 - sparse_categorical_accuracy: 0.9280
Epoch 468/500
27/27 [==============================] - 0s 967us/step - loss: 0.3924 - sparse_categorical_accuracy: 0.9221
Epoch 469/500
27/27 [==============================] - 0s 867us/step - loss: 0.3860 - sparse_categorical_accuracy: 0.9268
Epoch 470/500
27/27 [==============================] - 0s 981us/step - loss: 0.3791 - sparse_categorical_accuracy: 0.9315
Epoch 471/500
27/27 [==============================] - 0s 951us/step - loss: 0.4083 - sparse_categorical_accuracy: 0.9162
Epoch 472/500
27/27 [==============================] - 0s 864us/step - loss: 0.3800 - sparse_categorical_accuracy: 0.9268
Epoch 473/500
27/27 [==============================] - 0s 863us/step - loss: 0.4029 - sparse_categorical_accuracy: 0.9233
Epoch 474/500
27/27 [==============================] - 0s 837us/step - loss: 0.3787 - sparse_categorical_accuracy: 0.9433
Epoch 475/500
27/27 [==============================] - 0s 961us/step - loss: 0.3807 - sparse_categorical_accuracy: 0.9244
Epoch 476/500
27/27 [==============================] - 0s 901us/step - loss: 0.3782 - sparse_categorical_accuracy: 0.9351
Epoch 477/500
27/27 [==============================] - 0s 869us/step - loss: 0.3796 - sparse_categorical_accuracy: 0.9268
Epoch 478/500
27/27 [==============================] - 0s 909us/step - loss: 0.3827 - sparse_categorical_accuracy: 0.9374
Epoch 479/500
27/27 [==============================] - 0s 922us/step - loss: 0.3773 - sparse_categorical_accuracy: 0.9268
Epoch 480/500
27/27 [==============================] - 0s 880us/step - loss: 0.3920 - sparse_categorical_accuracy: 0.9292
Epoch 481/500
27/27 [==============================] - 0s 848us/step - loss: 0.3919 - sparse_categorical_accuracy: 0.9244
Epoch 482/500
27/27 [==============================] - 0s 858us/step - loss: 0.3953 - sparse_categorical_accuracy: 0.9162
Epoch 483/500
27/27 [==============================] - 0s 874us/step - loss: 0.3862 - sparse_categorical_accuracy: 0.9185
Epoch 484/500
27/27 [==============================] - 0s 862us/step - loss: 0.3797 - sparse_categorical_accuracy: 0.9339
Epoch 485/500
27/27 [==============================] - 0s 864us/step - loss: 0.4016 - sparse_categorical_accuracy: 0.9162
Epoch 486/500
27/27 [==============================] - 0s 946us/step - loss: 0.3896 - sparse_categorical_accuracy: 0.9339
Epoch 487/500
27/27 [==============================] - 0s 914us/step - loss: 0.3758 - sparse_categorical_accuracy: 0.9362
Epoch 488/500
27/27 [==============================] - 0s 891us/step - loss: 0.3861 - sparse_categorical_accuracy: 0.9303
Epoch 489/500
27/27 [==============================] - 0s 816us/step - loss: 0.3887 - sparse_categorical_accuracy: 0.9185
Epoch 490/500
27/27 [==============================] - 0s 809us/step - loss: 0.3923 - sparse_categorical_accuracy: 0.9233
Epoch 491/500
27/27 [==============================] - 0s 917us/step - loss: 0.3886 - sparse_categorical_accuracy: 0.9268
Epoch 492/500
27/27 [==============================] - 0s 905us/step - loss: 0.3853 - sparse_categorical_accuracy: 0.9221
Epoch 493/500
27/27 [==============================] - 0s 873us/step - loss: 0.3981 - sparse_categorical_accuracy: 0.9280
Epoch 494/500
27/27 [==============================] - 0s 946us/step - loss: 0.3809 - sparse_categorical_accuracy: 0.9315
Epoch 495/500
27/27 [==============================] - 0s 936us/step - loss: 0.3775 - sparse_categorical_accuracy: 0.9303
Epoch 496/500
27/27 [==============================] - 0s 908us/step - loss: 0.3800 - sparse_categorical_accuracy: 0.9386
Epoch 497/500
27/27 [==============================] - 0s 962us/step - loss: 0.3818 - sparse_categorical_accuracy: 0.9303
Epoch 498/500
27/27 [==============================] - 0s 939us/step - loss: 0.3777 - sparse_categorical_accuracy: 0.9256
Epoch 499/500
27/27 [==============================] - 0s 909us/step - loss: 0.3881 - sparse_categorical_accuracy: 0.9327
Epoch 500/500
27/27 [==============================] - 0s 2ms/step - loss: 0.3823 - sparse_categorical_accuracy: 0.9339 - val_loss: 0.4249 - val_sparse_categorical_accuracy: 0.9151

查看网络结构

# 查看网络结构
model.summary()
Model: "sequential_3"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 dense_9 (Dense)             (None, 30)                240       
                                                                 
 dense_10 (Dense)            (None, 90)                2790      
                                                                 
 dense_11 (Dense)            (None, 3)                 273       
                                                                 
=================================================================
Total params: 3,303
Trainable params: 3,303
Non-trainable params: 0
_________________________________________________________________

进行模型评估

# 划分一些测试集出来,选择后300行作为测试集
features_test = features_data[-300:]
labels_test = labels_data[-300:]
# 输出测试集
# print(features_test)
# print(labels_test)

# 评估模型
loss, accuracy = model.evaluate(features_test, labels_test)
print(f'模型的准确率为:{accuracy}')
10/10 [==============================] - 0s 997us/step - loss: 0.4143 - sparse_categorical_accuracy: 0.9167
模型的准确率为:0.9166666865348816

总结与分析

本文通过TensorFlow框架中的keras构建简单神经网络对牛奶质量进行分类(预测),首先对实验数据集进行预处理,将对象类型的数据转换为数值类型,并提取出特征列和标签列,以便于后续模型的训练;网络结构为三层全连接层, 第一层有30个神经元,激活函数为relu,第二层有90个神经元,激活函数为relu,第三层,也是输出层,有3个神经元,激活函数为softmax,更多的详细参数配置在上文分类过程中有所体现;通过对模型的评估,得到了超过90%的准确率,有一定的可用性,后续还可以通过调整模型参数提升效果。

你可能感兴趣的:(tensorflow,keras,神经网络,分类,深度学习)