Abstract: This article demonstrates how to build a simple ConvNet architecture using convolutional and pooling layers with the nolearn library, and how to train this ConvNet as a feature extractor. The extracted features can then be used with other models like SVM or logistic regression for classification tasks.

ConvNet architecture built with nolearn and used for feature extraction


Convolutional neural networks (CNNs) are inspired by biological processes and differ from traditional multi-layer perceptrons (MLPs) by using specialized layers such as convolutional and pooling layers. For those interested in CNNs, I highly recommend checking out the CS231n course on Convolutional Neural Networks for Visual Recognition. Here’s a brief overview of the CNN architecture:

Conventional neural network

Conventional neural network

ConvNet architecture

ConvNet architecture As you can see, CNNs operate on 3D data and use convolutional operations throughout the network. While I won’t go into full detail here, I encourage you to explore the CS231n tutorial if you're serious about understanding CNNs. Lasagne and nolearn are two powerful Python libraries for deep learning. Lasagne is built on top of Theano, offering efficient GPU acceleration and making it easier to define neural network structures. Nolearn is a wrapper around Lasagne that simplifies model creation, training, and layer inspection. In this article, I will show you how to construct a basic ConvNet using these tools, and how to use it as a feature extractor. Instead of training a full classifier, we’ll extract features from the network and feed them into other models like SVM or logistic regression. This approach is similar to transfer learning, where pre-trained networks (such as those trained on ImageNet) are used to extract general features for new tasks. Since early layers in CNNs often act as edge detectors, they can serve as useful features for various applications. Loading the MNIST Dataset The MNIST dataset is one of the most commonly used datasets for digit recognition. Let's start by importing the necessary packages: Import matplotlib Import matplotlib.pyplot as plt Import matplotlib.cm as cm From urllib import urlretrieve Import cPickle as pickle Import os Import gzip Import numpy as np Import theano Import lasagne From lasagne import layers From lasagne.updates import nesterov_momentum From nolearn.lasagne import NeuralNet From nolearn.lasagne import visualize From sklearn.metrics import classification_report From sklearn.metrics import confusion_matrix As shown, we’re importing modules for visualization, data handling, and model evaluation. Now, let's define a function to load the MNIST dataset: Def load_dataset(): Url = 'http://deeplearning.net/data/mnist/mnist.pkl.gz' Filename = 'mnist.pkl.gz' If not os.path.exists(filename): Print("Downloading MNIST dataset...") Urlretrieve(url, filename) With gzip.open(filename, 'rb') as f: Data = pickle.load(f) X_train, y_train = data[0] X_val, y_val = data[1] X_test, y_test = data[2] X_train = X_train.reshape((-1, 1, 28, 28)) X_val = X_val.reshape((-1, 1, 28, 28)) X_test = X_test.reshape((-1, 1, 28, 28)) Y_train = y_train.astype(np.uint8) Y_val = y_val.astype(np.uint8) Y_test = y_test.astype(np.uint8) Return X_train, y_train, X_val, y_val, X_test, y_test This function downloads the processed MNIST dataset and splits it into training, validation, and test sets. It also reshapes the images to fit the input format required by Lasagne and converts the labels to the correct data type. Now, let's load and display an example image: X_train, y_train, X_val, y_val, X_test, y_test = load_dataset() Plt.imshow(X_train[0][0], cmap=cm.binary) This code should display an image like the one below (using IPython Notebook):

An example of a MNIST digit (this is the number 5)

An example of a MNIST digit (this is the number 5) With the dataset loaded, we can now proceed to build and train our ConvNet.

Led Display Rent

Led display screen rent

This series of led display rent can be used in trade shows, concerts, exhibitions, indoor sports events, political rallies, award functions, weddings, even shopping arcades. These LED screens rent can be Up and/Down scaled to fit in any place. The credit goes to their modular design. The astonishing picture quality and clarity of LED display screens brings in visual delight that cannot be missed.

These systems have a strong build, are meant for rugged use and also have a flexible assembly and dismantle. Because of their scalable nature, these Stage LED display screen can be adjusted to fit in a wide range of sizes, character structure and different color options. They can be displayed in varied alternatives like mounted, hanging structure, etc.

Our stage LED display screen walls are characteristically light in weight with high contrast ratio and high refresh rate. This results in additional flexibility and better visual output without any lag or distortions. For the LED display rent, flight case, video processor, lock button & hanging structure is necessary since the screen needs to move from one site to another very frequently.

Led display rent , Led Screen rent, LED Rental Display, Led Screen Stage

Shenzhen Priva Tech Co., Ltd. , https://www.privaled.com