這篇文章主要講解了tensorflow pb to tflite精度下降的問題,內(nèi)容清晰明了,對(duì)此有興趣的小伙伴可以學(xué)習(xí)一下,相信大家閱讀完之后會(huì)有幫助。
成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)的關(guān)注點(diǎn)不是能為您做些什么網(wǎng)站,而是怎么做網(wǎng)站,有沒有做好網(wǎng)站,給創(chuàng)新互聯(lián)一個(gè)展示的機(jī)會(huì)來證明自己,這并不會(huì)花費(fèi)您太多時(shí)間,或許會(huì)給您帶來新的靈感和驚喜。面向用戶友好,注重用戶體驗(yàn),一切以用戶為中心。之前希望在手機(jī)端使用深度模型做OCR,于是嘗試在手機(jī)端部署tensorflow模型,用于圖像分類。
思路主要是想使用tflite部署到安卓端,但是在使用tflite的時(shí)候發(fā)現(xiàn)模型的精度大幅度下降,已經(jīng)不能支持業(yè)務(wù)需求了,最后就把OCR模型調(diào)用寫在服務(wù)端了,但是精度下降的原因目前也沒有找到,現(xiàn)在這里記錄一下。
工作思路:
1.訓(xùn)練圖像分類模型;2.模型固化成pb;3.由pb轉(zhuǎn)成tflite文件;
但是使用python 的tf interpreter 調(diào)用tflite文件就已經(jīng)出現(xiàn)精度下降的問題,android端部署也是一樣。
1.網(wǎng)絡(luò)結(jié)構(gòu)
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim def ttnet(images, num_classes=10, is_training=False, dropout_keep_prob=0.5, prediction_fn=slim.softmax, scope='TtNet'): end_points = {} with tf.variable_scope(scope, 'TtNet', [images, num_classes]): net = slim.conv2d(images, 32, [3, 3], scope='conv1') # net = slim.conv2d(images, 64, [3, 3], scope='conv1_2') net = slim.max_pool2d(net, [2, 2], 2, scope='pool1') net = slim.batch_norm(net, activation_fn=tf.nn.relu, scope='bn1') # net = slim.conv2d(net, 128, [3, 3], scope='conv2_1') net = slim.conv2d(net, 64, [3, 3], scope='conv2') net = slim.max_pool2d(net, [2, 2], 2, scope='pool2') net = slim.conv2d(net, 128, [3, 3], scope='conv3') net = slim.max_pool2d(net, [2, 2], 2, scope='pool3') net = slim.conv2d(net, 256, [3, 3], scope='conv4') net = slim.max_pool2d(net, [2, 2], 2, scope='pool4') net = slim.batch_norm(net, activation_fn=tf.nn.relu, scope='bn2') # net = slim.conv2d(net, 512, [3, 3], scope='conv5') # net = slim.max_pool2d(net, [2, 2], 2, scope='pool5') net = slim.flatten(net) end_points['Flatten'] = net # net = slim.fully_connected(net, 1024, scope='fc3') net = slim.dropout(net, dropout_keep_prob, is_training=is_training, scope='dropout3') logits = slim.fully_connected(net, num_classes, activation_fn=None, scope='fc4') end_points['Logits'] = logits end_points['Predictions'] = prediction_fn(logits, scope='Predictions') return logits, end_points ttnet.default_image_size = 28 def ttnet_arg_scope(weight_decay=0.0): with slim.arg_scope( [slim.conv2d, slim.fully_connected], weights_regularizer=slim.l2_regularizer(weight_decay), weights_initializer=tf.truncated_normal_initializer(stddev=0.1), activation_fn=tf.nn.relu) as sc: return sc
網(wǎng)頁名稱:tensorflowpbtotflite精度下降的問題-創(chuàng)新互聯(lián)
鏈接URL:http://www.rwnh.cn/article10/ichgo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、網(wǎng)站改版、全網(wǎng)營銷推廣、定制網(wǎng)站、商城網(wǎng)站、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容