What is SoftmaxLayer in PyBrain? Last Updated : 21 Feb, 2022 Comments Improve Suggest changes Like Article Like Report SoftmaxLayer executes the softmax distribution from the given input dataset. We can build the network with input, hidden, and output layers using buildNetwork() function and we have used the hidden class as SoftmaxLayer to check the AND and NOR table values of the dataset. Below is the syntax to import SoftmaxLayer and usage in the code. Syntax: Import SoftmaxLayer: from pybrain.structure import SoftmaxLayer Usage in python code: net= buildNetwork(1, 2, 1, bias=True, hiddenclass=SoftmaxLayer) Example 1: In this example, we import the SoftmaxLayer using the import command to create the network using buildNetwork() with input, hidden, and output layer. We take a hidden class as SoftmaxLayer, Now give the sizes of input and output dataset using SupervisedDataSet(). To add sample dataset to AND table and NOR table. Then train this network using BackpropTrainer(). We have 2500 iterations and then testing starts and we can see the errors, corrections, max, errors, etc.In this case, the sample data we have taken in AND table are ((0,0), (1,)) and ((0,1),(0,)) and NOR table are ((0,0),(1,)) and (0,1),(0,)) Python3 from pybrain.tools.shortcuts import buildNetwork from pybrain.structure import SoftmaxLayer from pybrain.datasets import SupervisedDataSet from pybrain.supervised.trainers import BackpropTrainer # two inputs, two hidden, and single output with hiddenlayer as Softmaxlayer net = buildNetwork(2, 3, 1, bias=True, hiddenclass=SoftmaxLayer) # size of inputs and outputs gate_set = SupervisedDataSet(2, 1) test_dataset = SupervisedDataSet(2, 1) # AND truth table gate_set.addSample((0, 0), (1,)) gate_set.addSample((0, 1), (0,)) # NOR truth table test_dataset.addSample((0, 0), (1,)) test_dataset.addSample((0, 1), (0,)) #Train the network using net and gate_set. backpr_tr = BackpropTrainer(net, gate_set) # 2500 iteration for i in range(1500): backpr_tr.train() # Testing.... backpr_tr.testOnData(dataset=test_dataset, verbose = True) Output: Example 2: In this example, we have taken the sample dataset in AND table are ((0,0), (0,)) and ((0,1),(1,)) and NOR table are ((0,0),(1,)) and (0,1),(1,)) and then training starts to train this network using 2500 iterations and finally testing starts. We can see the testing output with average errors, max errors, median errors, etc. Python3 from pybrain.tools.shortcuts import buildNetwork from pybrain.structure import SoftmaxLayer from pybrain.datasets import SupervisedDataSet from pybrain.supervised.trainers import BackpropTrainer # two inputs, two hidden, and single output # with hiddenlayer as Softmaxlayer net = buildNetwork(2, 3, 1, bias=True, hiddenclass=SoftmaxLayer) # size of inputs and outputs gate_set = SupervisedDataSet(2, 1) test_dataset = SupervisedDataSet(2, 1) # AND truth table gate_set.addSample((0, 0), (0,)) gate_set.addSample((0, 1), (1,)) # NOR truth table test_dataset.addSample((0, 0), (1,)) test_dataset.addSample((0, 1), (1,)) #Train the network using net and gate_set. backpr_tr = BackpropTrainer(net, gate_set) # 2500 iteration for i in range(1500): backpr_tr.train() # Testing.... backpr_tr.testOnData(dataset=test_dataset, verbose = True) Output: Comment More infoAdvertise with us Next Article What is SoftmaxLayer in PyBrain? singh_teekam Follow Improve Article Tags : Machine Learning Geeks Premier League AI-ML-DS Geeks-Premier-League-2022 python Python-PyBrain +1 More Practice Tags : Machine Learningpython Similar Reads Python Tutorial | Learn Python Programming Language Python Tutorial â Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly.Python is:A high-level language, used in web development, data science, automatio 10 min read Machine Learning Tutorial Machine learning is a branch of Artificial Intelligence that focuses on developing models and algorithms that let computers learn from data without being explicitly programmed for every task. In simple words, ML teaches the systems to think and understand like humans by learning from the data.It can 5 min read Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Linear Regression in Machine learning Linear regression is a type of supervised machine-learning algorithm that learns from the labelled datasets and maps the data points with most optimized linear functions which can be used for prediction on new datasets. It assumes that there is a linear relationship between the input and output, mea 15+ min read Support Vector Machine (SVM) Algorithm Support Vector Machine (SVM) is a supervised machine learning algorithm used for classification and regression tasks. It tries to find the best boundary known as hyperplane that separates different classes in the data. It is useful when you want to do binary classification like spam vs. not spam or 9 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Logistic Regression in Machine Learning Logistic Regression is a supervised machine learning algorithm used for classification problems. Unlike linear regression which predicts continuous values it predicts the probability that an input belongs to a specific class. It is used for binary classification where the output can be one of two po 11 min read K means Clustering â Introduction K-Means Clustering is an Unsupervised Machine Learning algorithm which groups unlabeled dataset into different clusters. It is used to organize data into groups based on their similarity. Understanding K-means ClusteringFor example online store uses K-Means to group customers based on purchase frequ 4 min read K-Nearest Neighbor(KNN) Algorithm K-Nearest Neighbors (KNN) is a supervised machine learning algorithm generally used for classification but can also be used for regression tasks. It works by finding the "k" closest data points (neighbors) to a given input and makesa predictions based on the majority class (for classification) or th 8 min read Like