Get weights and biases of a particular layer of NN in MXNet

In this recipe, we will see how to get weights and biases of a particular layer of NN in MXNet

Recipe Objective: How to get weights and biases of a particular layer of NN in MXNet?

This recipe explains how to get weights and biases of a particular layer of NN in MXNet.

Learn to Build a Multi Class Image Classification Model in Python from Scratch

Step 1: Importing library

Let us first import the necessary libraries. We'll import the neural network (nn alias) package from mxnet.gluon

from mxnet.gluon import nn

Step 2: Chain Layer

We can chain layers into the neural network with the help of sequential. We execute the layers sequentially, one after another. The layers are piled in the same manner they are defined. Its index can access any layer.

layer = nn.Sequential()
layer.add(nn.Dense(720,in_units=3,activation='relu'),
    nn.Dense(316, activation='relu'), nn.Dense(10))
layer[1]

Step 3: Weights and Biases

We can access weights and bias with the .data() method. We can access the weight or bias of a specific layer by using its index.

layer[0].weight.data()
layer[2].bias.data()

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

Hands-On Approach to Causal Inference in Machine Learning
In this Machine Learning Project, you will learn to implement various causal inference techniques in Python to determine, how effective the sprinkler is in making the grass wet.

End-to-End Snowflake Healthcare Analytics Project on AWS-2
In this AWS Snowflake project, you will build an end to end retraining pipeline by checking Data and Model Drift and learn how to redeploy the model if needed

MLOps Project for a Mask R-CNN on GCP using uWSGI Flask
MLOps on GCP - Solved end-to-end MLOps Project to deploy a Mask RCNN Model for Image Segmentation as a Web Application using uWSGI Flask, Docker, and TensorFlow.

Recommender System Machine Learning Project for Beginners-1
Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

End-to-End Snowflake Healthcare Analytics Project on AWS-1
In this Snowflake Healthcare Analytics Project, you will leverage Snowflake on AWS to predict patient length of stay (LOS) in hospitals. The prediction of LOS can help in efficient resource allocation, lower the risk of staff/visitor infections, and improve overall hospital functioning.

Recommender System Machine Learning Project for Beginners-2
Recommender System Machine Learning Project for Beginners Part 2- Learn how to build a recommender system for market basket analysis using association rule mining.

Build Classification Algorithms for Digital Transformation[Banking]
Implement a machine learning approach using various classification techniques in Python to examine the digitalisation process of bank customers.

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

Build a Graph Based Recommendation System in Python-Part 2
In this Graph Based Recommender System Project, you will build a recommender system project for eCommerce platforms and learn to use FAISS for efficient similarity search.

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.