Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deep-diver/logistic-regression

simple neural network without hidden layer
https://github.com/deep-diver/logistic-regression

logistic-regression neural-network numpy

Last synced: 29 days ago
JSON representation

simple neural network without hidden layer

Awesome Lists containing this project

README

        

# Simple Neural Network without hidden layer

This repository is to demonstrate a simple neural networks without hidden layers. All the functions to build the neural networks are written in numpy. The simple model takes a batch of images of cat in shape shown below figure, and then it performs prediction.

![alt text](/images/capture1.png)

## The flow
### 1. **main** function
- get the image datasets, then flatten and normalize them.
- build and train the model
- print out relative informations
### 2. **model** function
- initialize parameters by calling **initialize_with_zeros** function
- optimize the parameters by training on the training dataset. This is done by calling **optimize** function
- run prediction on training and testing datasets by calling **predict** function
- return cost, predictions, updated w and b, and etc.
### 3. **initialize_with_zeros** function
- simply initialize the parameters, w and b
- this is done by **numpy.zeros** function
### 4. **optimize** function
- iterating for the number of iterations given as a hyper-parameter
- while iterating it calculates gradient decent and costs by calling **propagate** function. also, update the parameters, w and b with the calculated gradient decent
- return the final values of parameters and gradient decent
### 5. **propagate** function
- performs calculation in the following order
- **sigmoid** function as the activation function on w, X, and b ![alt text](/images/activatoin.PNG)
- calculate the cost function J
![alt text](./images/cost.PNG)
- calculate the gradient decent on w and b
- ![alt text](/images/dw.PNG)
- ![alt text](/images/db.PNG)
- ![alt text](/images/capture2.png)
return them
### 6. **predict** function
- simply running **sigmoid** function on w, X, and b. with the result of the **sigomid** function (a), it returns 0 if a <= 0.5, and it returns 1 otherwise.
### 7. **sigmoid** function
- simply calculate and return
![alt text](./images/sigmoid.PNG)

## Dependencies
- **numpy**
- for handy matrix operations
- http://www.numpy.org/
- **h5py**
- Pythonic interface to the HDF5 binary data format.
- Image dataset is stored in h5 file format.
- https://www.h5py.org/

## Reference
- Coursera Deeplearning.ai (by Andrew Ng.)
- https://www.coursera.org/learn/neural-networks-deep-learning/notebook/Zh0CU/python-basics-with-numpy-optional