[ESP32]:TFLite Micro推理CIFAR10模型
模型训练
数据集处理
from keras.datasets import cifar10
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential, load_model, Model
from keras.layers import Input, Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D, GlobalAveragePooling2D
import pandas as pd
import matplotlib.pyplot as plt
import time, pickle
from keras.utils import to_categorical
from keras import layers
import tensorflow as tf
from tensorflow.keras.callbacks import EarlyStopping
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
y_train = y_train.reshape(y_train.shape[0])
y_test = y_test.reshape(y_test.shape[0])
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'training samples')
print(x_test.shape[0], 'validation samples')
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
y_train = to_categorical(y_train, 10)
y_test = to_categorical(y_test, 10)
模型搭建
def build_model():
model = tf.keras.Sequential(

本文介绍了如何在ESP32平台上使用TensorFlowLiteMicro进行CIFAR10数据集的2D卷积神经网络模型训练,随后将模型转换为TFLite格式,并提供了两种推理方案:PC端JPEG图片转换为数组和ESP32本地JPEG解码。
最低0.47元/天 解锁文章
791

被折叠的 条评论
为什么被折叠?



