zoukankan      html  css  js  c++  java
  • 暑假第五周

    这周进行的主要是手写数字的卷积神经网络的编写,不过由于对于自己来说难度较大,只写了第一层卷积。
    import numpy as np
    import matplotlib.pyplot as plt
    import tensorflow as tf
    import time from datetime
     import timedelta
    import math from tensorflow.examples.tutorials.mnist import input_data
    def weights(shape):     
    return tf.Variable(tf.truncated_normal(shape,stddev=0.05))
    def biases(length):    
    return tf.Variable(tf.constant(0.1,shape=length))
    def conv2d(a,b):     
    return tf.nn.conv2d(a,b,strides=[1,1,1,1],padding='SAME')
    def max_pool_2x2(inputx):     
    return tf.nn.max_pool(inputx,ksize=[1,2,2,1],strides=[1,2,2,1],padding='SAME')
    data = input_data.read_data_sets("./data", one_hot=True)
    print("Size of:")
    print("--Training-set: {}".format(len(data.train.labels)))
    print("--Testing-set: {}".format(len(data.test.labels)))
    print("--Validation-set: {}".format(len(data.validation.labels)))
    data.test.cls = np.argmax(data.test.labels,axis=1)
    x = tf.placeholder("float",shape=[None,784],name='x')
    x_image = tf.reshape(x,[-1,28,28,1])
    y_true = tf.placeholder("float",shape=[None,10],name='y_true')
    y_true_cls = tf.argmax(y_true,dimension=1)
    layer_conv1 = {"weights":weights([5,5,1,32]),"biases":biases([32])}
    h_conv1 = tf.nn.relu(conv2d(x_image,layer_conv1["weights"])+layer_conv1["biases"])
    h_pool1 = max_pool_2x2(h_conv1)
    下周尽量完成手写数字。
  • 相关阅读:
    学习PetShop3.0(9)工厂的资料
    net程序架构开发
    《解剖PetShop》系列之一
    与数据库相关的名词解释
    asp 导出Excel
    《解剖PetShop》系列之二
    业务模块的设计原则
    《解剖PetShop》系列之三
    JAVA之BigInteger(转)【转】【很好用啊】
    php_mcrypt.dll无法加载解决方法
  • 原文地址:https://www.cnblogs.com/studya/p/11335774.html
Copyright © 2011-2022 走看看