- 
            
            1、轻量级 2、python语言进行编写 训练步骤: 1、下载数据集 2、编写训练程序 3、训练模型 4、验证训练的模型 调用步骤 1、使用训练好的模型 2、定义参数 3、通过端进行传参(web前端页面、绘图仪、手写板) 4、数据验证并返回 暴露接口 可以使用TensorFlow Serving部署成grpc模式的接口 flask 整合步骤 1、训练生成模型 2、暴露接口 3、前端调用 4、验证并返回结果 查看全部
- 
            
            完成了使用flask创建api接口,调用训练好的网络 进行网页端的手写数字识别 查看全部
- 
            
            通过链接前端的界面 实现了卷积神经网络实时分类输入的手写数字 使用(255-x)/255将0到255的值转化到0到1之间 查看全部
- 
            
            在flask中注册api的url 来调用训练好的模型 @app.route('/api/mnist', methods=['post']) def mnist(): input = ((255 - np.array(request.json, dtype=np.uint8)) / 255.0).reshape(1, 784) output1 = regression(input) output2 = convolutional(input) return jsonify(results=[output1, output2]) if __name__ == '__main__': app.run()查看全部
- 
            
            完成卷积神经网络的训练 with tf.Session() as sess: merged_summary_op = tf.summary.merge_all() summary_writer = tf.summary.FileWriter('/tmp/mnist_log/1', sess.graph) summary_writer.add_graph(sess.graph) sess.run(tf.global_variables_initializer()) for i in range(20000): batch = data.train.next_batch(50) if i % 100 == 0: train_accuracy = accuracy.eval(feed_dict={x: batch[0], _y: batch[1], keep_prob: 1.0}) print("step %d, train accuracy=%d" % (i, train_accuracy)) sess.run(train_step, feed_dict={x: batch[0], _y: batch[1], keep_prob: 0.5}) print(sess.run(accuracy, feed_dict={x: data.test.images, _y: data.test.labels, keep_prob: 1.0})) path = saver.save(sess, os.path.join(os.path.dirname(__file__), 'data', 'convalution.ckpt'), write_meta_graph=False, write_state=False) print("Saved:", path)查看全部
- 
            
            在卷积层中调用模型文件 from mnist import model data = read_data_sets('MNIST_data', one_hot=True) with tf.variable_scope('convolutional'): x = tf.placeholder(tf.float32, [None, 784]) keep_prob = tf.placeholder(tf.float32) y, variables = model.convolutional(x,keep_prob) _y = tf.placeholder(tf.float32, [None, 10]) cross_entropy = -tf.reduce_sum(_y * tf.log(y)) train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy) correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(_y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) saver=tf.train.Saver(variables) with tf.Session() as sess: merged_summary_op = tf.summary.merge_all() summary_writer = tf.summary.FileWriter('/tmp/mnist_log/1', sess.graph) summary_writer.add_graph(sess.graph)查看全部
- 
            
            完成剩余的卷积神经网络模型 W_conv2 = weight_variable([5, 5, 32, 64]) b_conv2 = bias_variable([64]) h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2) h_pool2 = max_pool_2x2(h_conv2) W_fc1 = weight_variable([7 * 7 * 64, 1024]) b_fc1 = bias_variable([1024]) h_pool2_flat = tf.reshape(h_pool2, [-1, 7 * 7 * 64]) h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1) h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob) W_fc2 = weight_variable([1024, 10]) b_fc2 = bias_variable([10]) y = tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2) return y, [W_conv1, b_conv1, W_conv2, b_conv2, W_fc1, b_fc1, W_fc2, b_fc2] 查看全部
- 
            
            简单构建cnn的网络 def convolutional(x, keep_prob): def conv2d(x, W): return tf.nn.conv2d([1, 1, 1, 1], padding='SAME') def max_pool_2x2(x): return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') def weight_variable(shape): initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial) def bias_variable(shape): initial = tf.constant(0.1, shape=shape) return tf.Variable(initial) x_image = tf.reshape(x, [-1, 28, 28, 1]) W_conb1 = weight_variable([5, 5, 1, 32]) b_conv1 = bias_variable([32]) h_conv1 = tf.nn.relu(conv2d(x_image, W_conb1) + b_conv1) h_pool1 = max_pool_2x2(h_conv1) 查看全部
- 
            
            完成线性模型的构建 import tensorflow as tf import os from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets from mnist import model data = read_data_sets('MNIST_data', one_hot=True) with tf.variable_scope('regression'): x = tf.placeholder(tf.float32, [None, 784]) y, variables = model.regression(x) _y = tf.placeholder('float', [None, 10]) cross_entropy = -tf.reduce_sum(_y * tf.log(y)) train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy) correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(_y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) saver=tf.train.Saver(variables) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for _ in range(1000): batch_xs,batch_ys=data.train.next_batch(100) sess.run(train_step,feed_dict={x:batch_xs,_y:batch_ys}) print(sess.run(accuracy,feed_dict={x:data.test.images,_y:data.test.labels})) path=saver.save(sess,os.path.join(os.path.dirname(__file__),'data','regression.ckpt'),write_meta_graph=False,write_state=False) print('Saver:'+path)最终保存了训练好的模型 查看全部
- 
            
            进行模型的构建 先是线性模型 import tensorflow as tf from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets from mnist import model data = read_data_sets('MNIST_data', one_hot=True) with tf.variable_scope('regression'): x = tf.placeholder(tf.float32, [None, 784]) y, variables = model.regression(x) _y = tf.placeholder('float', [None, 10]) cross_entropy = -tf.reduce_sum(_y * tf.log(y)) train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy) correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(_y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))查看全部
- 
            
            使用tensorflow提供的函数来 下载官方的mnist数据集 查看全部
- 
            
            flask一种轻量的web框架 训练好模型 使用flask来调用模型 查看全部
- 
            
            mnist数据集是手写数字数据集 包含0到9的手写数字图片 可以用来训练深度学习网络 查看全部
- 
            
            tensorflow是一个深度学习库 支持cnn rnn lstm等 可以实现语音识别和图像识别 查看全部
- 
            
            将人工智能与现有的技术相结合 可以进一步提高使用体验 tensorflow与flask结合 查看全部
- 
            
            MNIST 查看全部
- 
            
            整合步骤。 查看全部
- 
            
            MNIST查看全部
- 
            
            MNIST 查看全部
- 
            
            TensorFlow 查看全部
- 
            
            人工智能。 查看全部
- 
            
            (@#%&*_/)1358694270查看全部
- 
            
            训练步骤查看全部
- 
            
            MNIST数据集 查看全部
- 
            
            怎么没人呢 查看全部
- 
            
            我就过来看看 查看全部
- 
            
            1.首先使用mnist来input数据,之后建立模型,调用模型,训练模型,把模型结果保存,然后在main.py中把模型拿出来取用,然后前端传进来之后调用模型。 2.还可以引申来分类一些图像,分类一些动物,做自然语言处理,来做一个聊天机器人,或者训练生成古诗词,都可以使用上面的方法。我们只要把模型训练好之后,通过Flask调用模型载入进来,白鹭给API的接口,供我们后期的使用。 查看全部
- 
            
            1.启动之后需要调用,如何调用呢?需要编写一个前端界面。 2.写好前端页面之后需要将index.html和main.py绑定。 @app.route('/') # 将index.html和main.py绑定 def main(): return render_template('index.html') 3.在这个项目中,数据是如何传递的呢以及如何进行交互的呢? 数据在前端界面输入后,先传到main.js,使用data来进行转换格式和传到后台,调用模型之后把结果放到output1和output2,打包成json格式返回给前端,展示。 查看全部
举报
 
             
         
                 
                 
                 
                 
                 
                 
                