Giter VIP home page Giter VIP logo

fc-tensorflow-mnist-practice's Introduction

FC-TensorFlow-MNIST-PRACTICE

Use Tensorflow to establish a fully connected neural network to identify my own handwritten numbers. The result isn't ideal. And it has a very pool recognition of 6.

What's more, there is a commented function(reconstruct_imge()) in the program.

def reconstruct_image():
    for i in range(10):
        if not os.path.exists('./SAMPLE'.format(i)):
            os.mkdir('./SAMPLE'.format(i))
        if not os.path.exists('./SAMPLE/{}'.format(i)):
            os.mkdir('./SAMPLE/{}'.format(i))
    #根据label分发为28*28规格的图片
    batch_size = 1
    for i in range(int(mnist.train.num_examples / batch_size)):
        #x_data = [[784]], y_data = [[10]]
        x_data, y_data = mnist.train.next_batch(batch_size)
        img = Image.fromarray(np.reshape(np.array(x_data[0] * 255, dtype = 'uint8'), newshape = (28,28)))#将图片的格式转化成Image能用的格式
        dir = np.argmax(y_data[0])
        img.save('./SAMPLE/{}/{}.bmp'.format(dir, i))

You can run this function to unzip the souce MNIST data, and convert the numbers to a 28*28 .bmp file.It can help you to impove the accuracy.

066

I put part of the data source in the SAMPLE folder. You will find that they are all white on black.

Besides, I used the drawing in Windows to draw the picture below. In order to improve the recognition, I painted the background of the picture as black. And the image is expanded and etched by the Opencv library in Python. 3

The files checkpoint, mnist.ckpt.data-00000-of-00001, mnist.ckpt.index and mnist.ckpt.meta are a FC nerual network that I have trained for 3000 times. And its accuracy is 0.953. The same situation is that, it also has a very pool recognition of number 6.

Put these files in the same path to run the fcnn.py file. You can save nearly 45 minutes.

reference: Peter_Chan in Bilibili, TensorFlow系列教程(2)——手写数字的识别

       https://docs.opencv.org/4.0.0/
       
       https://tensorflow.google.cn/

fc-tensorflow-mnist-practice's People

Contributors

yukiiwong avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.