GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MachineLearning/NN at master · carefree0910/MachineLearning

Expand file tree

/

NN

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

NN

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Basic
Basic
 
 
PyTorch
PyTorch
 
 
TF
TF
 
 
Test
Test
 
 
Errors.py
Errors.py
 
 
NN.py
NN.py
 
 
README.md
README.md
 
 

README.md

Outline

NN

Implemented NN & CNN with Numpy & Tensorflow & PyTorch

Visualization

Neural Network on Spiral

Examples

Visualize Network

from NN.Basic.Networks import *
from Util.Util import DataUtil

nn = NNDist()

x, y = DataUtil.gen_spiral(50, 3, 3, 2.5)

nn.build([x.shape[1], 6, 6, 6, y.shape[1]])  # Build a neural network on the fly (With ReLU + Cross Entropy)
nn.optimizer = "Adam"                        # Use Adam algorithms for training 
nn.preview()                                 # Preview network structure    
nn.fit(x, y, verbose=1, record_period=4, epoch=1000, train_only=True,
       draw_detailed_network=True, show_animation=True, make_mp4=True)
                                             # Visualize network & make an mp4 file                    
nn.draw_results()                            # Draw results (Training curve & loss curve)
nn.visualize2d(x, y)                         # Visualize result (2d)
nn.show_timing_log()                         # Show timing log

Result

See the GIF above

Mnist

from NN.NN import *
from Util.Util import DataUtil

x, y = DataUtil.get_dataset("mnist", "../../_Data/mnist.txt", quantized=True, one_hot=True)
                                             # Get tiny mnist dataset
x = x.reshape(len(x), 1, 28, 28)             # Reshape x to 4d array

nn = NNDist()

# # Neural Network
# nn.add("ReLU", (x.shape[1], 24))
# nn.add("ReLU", (24, ))
# nn.add("CrossEntropy", (y.shape[1], ))

# Convolutional Neural Network
nn.add("ConvReLU", (x.shape[1:], (32, 3, 3)))
nn.add("ConvReLU", ((32, 3, 3),))
nn.add("MaxPool", ((3, 3),), 2)
nn.add("ConvNorm")
nn.add("ConvDrop")
nn.add("ConvReLU", ((64, 3, 3),), std=0.01)
nn.add("ConvReLU", ((64, 3, 3),), std=0.01)
nn.add("AvgPool", ((3, 3),), 2)
nn.add("ConvNorm")
nn.add("ConvDrop")
nn.add("ConvReLU", ((32, 3, 3),))
nn.add("ConvReLU", ((32, 3, 3),))
nn.add("AvgPool", ((3, 3),), 2)
nn.add("ReLU", (512,))
nn.add("Identical", (64,))
nn.add("Normalize", activation="ReLU")
nn.add("Dropout")
nn.add("CrossEntropy", (y.shape[1],))

nn.optimizer = "Adam"
nn.preview()                     
nn.fit(x, y, verbose=2, do_log=True, show_loss=True)
                                             # Train network 
nn.draw_results()                            # Draw results (Training curve & loss curve)
nn.show_timing_log()                         # Show timing log
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.