偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Hi3861使用NNOM實現(xiàn)人工智能神經(jīng)網(wǎng)絡(luò)之MNIST

系統(tǒng) OpenHarmony
每當(dāng)我們學(xué)習(xí)一門新的語言時,所有的入門教程官方都會提供一個典型的例子——“Hello World”。而在機(jī)器學(xué)習(xí)中,入門的例子稱之為MNIST。

??想了解更多關(guān)于開源的內(nèi)容,請訪問:??

??51CTO 開源基礎(chǔ)軟件社區(qū)??

??https://ost.51cto.com??

1、什么是NNOM

請查看之前的帖子:https://ost.51cto.com/posts/12287

2、什么是MNIST

每當(dāng)我們學(xué)習(xí)一門新的語言時,所有的入門教程官方都會提供一個典型的例子——“Hello World”。而在機(jī)器學(xué)習(xí)中,入門的例子稱之為MNIST。

MNIST是一個簡單的視覺計算數(shù)據(jù)集,它是像下面這樣手寫的數(shù)字圖片:

MNIST 經(jīng)常被用來做為分類任務(wù)的入門數(shù)據(jù)庫使用。在這個簡單的例子里面,我們也用它來試試數(shù)據(jù)歸類。

3、移植和編譯

移植NNOM庫的方法,在之前已經(jīng)有說明。

$(wildcard $(LIBPATH)/nnom/src/backends/*.c) \
$(wildcard $(LIBPATH)/nnom/src/core/*.c) \
$(wildcard $(LIBPATH)/nnom/src/layers/*.c) \

同時移植了mnist-simple下面的兩個.h文件。

#include "lib/nnom/examples/mnist-simple/image.h"
#include "lib/nnom/examples/mnist-simple/weights.h"

核心的幾個函數(shù)。

const char codeLib[] = "@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\"^`'.   ";
void print_img(int8_t * buf)
{
for(int y = 0; y < 28; y++)
{
for (int x = 0; x < 28; x++)
{
int index = 69 / 127.0 * (127 - buf[y*28+x]);
if(index > 69) index =69;
if(index < 0) index = 0;
DEBUG_printf("%c",codeLib[index]);
DEBUG_printf("%c",codeLib[index]);
}
DEBUG_printf("\n");
}
}
// Do simple test using image in "image.h" with model created previously.
void mnist(int index)
{
uint32_t tick, time;
uint32_t predic_label;
float prob;
DEBUG_printf("\nprediction start.. \n");
tick = hi_get_milli_seconds();
// copy data and do prediction
memcpy(nnom_input_data, (int8_t*)&img[index][0], 784);
nnom_predict(model, &predic_label, &prob);
time = hi_get_milli_seconds() - tick;
//print original image to console
print_img((int8_t*)&img[index][0]);
DEBUG_printf("Time: %d tick\n", time);
DEBUG_printf("Truth label: %d\n", label[index]);
DEBUG_printf("Predicted label: %d\n", predic_label);
DEBUG_printf("Probability: %d%%\n", (int)(prob*100));
}
void nn_stat()
{
model_stat(model);
printf("Total Memory cost (Network and NNoM): %d\n", nnom_mem_stat());
}

4、MNIST使用

我是在Micropython下使用的,其實主要的幾個函數(shù),如下,可以自行移植測試。

STATIC mp_obj_t machine_ai_nnom_test(mp_obj_t self_in,mp_obj_t data_in) {
int num = mp_obj_get_int(data_in);
// create and compile the model
model = nnom_model_create();
// dummy run
model_run(model);
mnist(num);
nn_stat();
return mp_const_none;
}

不同的num值,代表候選的要識別的數(shù)字的字節(jié)圖。比如8,存儲的字節(jié)符合是這樣的。

因為不方便輸入手寫數(shù)字,只能通過這種字符的形式進(jìn)行測試。

5、總結(jié)

這是比較簡單的例子,對系統(tǒng)的要求的比較低,識別的時間也很短。同時,也可以自己訓(xùn)練模型,進(jìn)行分析。但該部分不是本文的重點,敢興趣的同學(xué),可以自行去github上,進(jìn)行深入的學(xué)習(xí)。下一篇,會針對KWS的功能測試,實現(xiàn)實時音頻輸入關(guān)鍵詞識別的demo的移植和演示。

??想了解更多關(guān)于開源的內(nèi)容,請訪問:??

??51CTO 開源基礎(chǔ)軟件社區(qū)??

??https://ost.51cto.com??。

責(zé)任編輯:jianghua 來源: 鴻蒙社區(qū)
相關(guān)推薦

2020-12-21 08:00:00

人工智能深度學(xué)習(xí)神經(jīng)網(wǎng)絡(luò)

2017-04-06 18:34:16

人工智能

2023-05-09 14:24:32

大數(shù)據(jù)人工智能

2022-03-02 14:53:34

人工智能神經(jīng)網(wǎng)絡(luò)

2022-11-30 07:12:06

2021-09-24 12:00:40

人工智能AI神經(jīng)網(wǎng)絡(luò)

2022-03-15 15:00:59

Hi3861Pin接口鴻蒙

2018-07-03 16:10:04

神經(jīng)網(wǎng)絡(luò)生物神經(jīng)網(wǎng)絡(luò)人工神經(jīng)網(wǎng)絡(luò)

2015-05-11 10:58:04

神經(jīng)網(wǎng)絡(luò)人工智能憶阻器

2023-11-15 16:12:41

人工智能機(jī)器學(xué)習(xí)深度學(xué)習(xí)

2020-10-12 09:36:04

鴻蒙

2017-03-16 14:34:25

人工智能神經(jīng)網(wǎng)絡(luò)

2022-03-07 15:05:58

HTTPHi3861數(shù)據(jù)解析

2020-10-16 09:50:37

Hi3861WiFi熱點

2018-04-25 09:07:41

人工智能神經(jīng)網(wǎng)絡(luò)

2018-02-06 15:40:50

2021-09-09 10:06:09

鴻蒙HarmonyOS應(yīng)用

2021-10-25 22:42:47

人工智能網(wǎng)絡(luò)安全工具

2023-02-26 00:31:41

2023-05-26 16:07:14

Hi3861Wifi模塊
點贊
收藏

51CTO技術(shù)棧公眾號