GithubHelp home page GithubHelp logo

tobinatore / tensorflow-practice-repo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.74 MB

A repo I use for practicing tensorflow and keras.

Python 100.00%
tensorflow keras neural-networks lstm cnn cnn-keras image-classification stock-price-prediction

tensorflow-practice-repo's Introduction

tensorflow-practice-repo

A repository containing every project I created / will create to practice using tensorflow and keras.

Prerequisites

To run the scripts found in this repository, you'll need to install the following Python packages:

  • sklearn
  • matplotlib
  • numpy
  • pandas
  • tensorflow
  • pillow

Currently implemented:

  1. MNIST fashion classification
  2. CIFAR10 image classification
  3. Stock prediction

MNIST fashion classification

Often seen as the new "Hello World" of neural networks, classifying the data in the MNIST fashion dataset does not require a complicated neural network. I decided to use a simple 3-layer architecture, consisting of an input layer with 784 neurons, connected to a dense hidden layer with 128 neurons and the output layer, which has 10 neurons. The hidden layer uses relu as activation function, whereas the output layer uses softmax to calculate the confidence rating. After testing the model, an overview of the first 25 samples from the test set is displayed. Next to each image is a confidence chart, that shows how confident the model was when choosing the label.
An image showing different fashion items plus the label the model predicted.
As you can see, the model classified 22 out of 25 shown images correctly.

CIFAR10 image classification

The CIFAR10 dataset is a dataset consisting of 60,000 32x32 color images containing one of 10 object classes, with 6000 images per class. It is commonly used to train machine learning and computer vision algorithms. To effectively classify the images in the dataset and any images the user chooses, I implemented a relatively simple convolutional neural network (CNN).
My model consists of the following layers:

  • an input layer (shape 32x32x3)
  • a BatchNormalization layer
  • a Conv2D layer followed by a MaxPool2D layer (3 times = 6 layers)
  • a layer for flattening the input (keras.layers.Flatten)
  • a dense layer with 512 neurons
  • the output layer (dense) with 10 neurons

The script creating the model will save it in the same directory it resides in. You can then use the classification script to classify any image you like.

The model should have an accuracy somewhere in the high 70% range after 50 epochs. I'll try and optimize it when I've got a bit more time on my hands.

Stock prediction

An algorithm correctly and accurately prediction stock value has yet to be found, but predicting tendencies using a Long Short Term Memory network (LSTM) is already feasible and fairly easy.
To tackle that problem I am using a model with 9 layers. These layers (except for the output layer) are always an LSTM layer with 50 neurons followed by a dropout layer. This is to avoid overfitting. A dense layer with 1 neuron functions as the output layer.
After training and saving the model, it is used to predict the value of the stock. This prediction will then be overlaid over the actual data, to get a feeling of the accuracy of the prediction.
Here an example using Alphabet:
A chart showing the predicted values.
And one for Microsoft: A chart showing the predicted values.
As you can see, the prediction captures the general tendencies pretty well.

tensorflow-practice-repo's People

Contributors

tobinatore avatar

Watchers

 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.