Skip to content

Neural Networks

Vinay Kumar edited this page Mar 9, 2018 · 4 revisions

Neural Networks Approach

Data Preprocessing

From the data description, we can learn that the raw data is a sequence of images of size 512 x 512. Each data set either training or testing has a variable number of images. One way to visualize the data is to think of it as a video file. Apart from the width and height of the images, time is considered as the third dimension for this data set.

Data

When the images are loaded into a Numpy array, it will be of the form (No.of Images x Width x Height). This three-dimensional data is transformed into a two-dimensional array by a series of transformations.

  1. Transpose
    The data of the form (No.of Images x width x Height) will be transformed into (Width x Height x No.of Images).
    Example: t_imgs = np.transpose(imgs).
  2. Reshape
    The data of the form (Width x Height x No.of Images) will be reshaped to (Width * Height x No.of Images).
    Example: t_imgs.reshape(Width*Height, No.of Images).

After these transformations the data will be a huge matrix with the number of rows equal to the total number of pixels and each column represents the intensity value of that pixel at that particular time.

Labels

Training data consists of coordinate values of a pixel which are recognized to be part of neurons. These pixels are identified either hand labeling or statistical methods. Each identified neuron is represented in the group of pixels surrounding the neuron. Labels for entire data set are provided in a JSON file and each object represents a neuron.

All the pixel coordinates are added to a python list.

A zero matrix of dimensions (Width x Height) is created and 1's are placed at coordinates of neuron pixels using zip function.

This gives a two-dimensional matrix of 0's and 1's of shape (Width x Height). This matrix is further reshaped to a matrix of shape (Width*Height, 1).

The labels for our model is a two-dimensional matrix with rows as pixel and column as one hot-key encoding.

Model

The model is a dense neural network with aim of binary classification. Each pixel is classified as neuron or non-neuron.

Two different neural networks were created, one with 18 hidden layers making it extremely dense and the other with 2 layers including input and output layers.

All the layers except the output layer have a ReLu activation function and the output layer has a Sigmoid function to support binary classification.

Network

    1. Consists of 20 layers out of which 18 layers are hidden layers.
    2. Consists of 4 layers with 2 hidden layers.
  • Activation function: ReLu, Sigmoid
  • Loss Function: Binary Cross Entropy
  • Optimizer: Adam, SGD
  • Epochs: 50, 150
  • Batch size: 5, 50, 500

Post-processing

  • The output of the network is a two-dimensional matrix of shape (Width * Height x 1).
  • This output is resized into an image shape (Width x Height) to form a binary image.
  • Blob Detection: OpenCV Contours are used to extract the neurons to a two dimensional list.
  • These lists can be written to a JSON file using Python JSON package.
Clone this wiki locally