PART 3 (15pts) BUILDING NN CLASSIFIER
Given the following
CLASSIFICATION DATA D (with objects)
O a1 a2 a3 C
o1 0.5 0 0.2 1
o2 0 0.3 0 1
o3 0.4 0.1 0.5 0
o4 0.3 0.2 0.2 1
o5 0.1 0 0.4 1
o6 0.4 0.3 0.2 0
Design a full classification NEURAL NETWORK for D with ONE HIDDEN LAYER with 2 NODES
Draw your full classification NEURAL NETWORK picture numbering INPUT, HIDDEN LAYER and
OUTPUT NODES by numbers 1, 2, ... 6 and specifying corresponding WEIGHTS
Assistant
To design a full classification neural network for D with one hidden layer and 2 nodes, we can follow the steps:
User
Perform only ONE EPOCH training with records o1 − o4 and with all initial weights and bias set as follows.
w14 = w15 = w24 = w25 = w34 = 0.500, w35 = w46 = w56 = 0.5, and biases B4 = B5 = B6 = 0.5.
Set the learning rate lr = 0.2. You should use sigmoid activation function f(t) =
1/(1+e^−t) at each output layer
Assistant
To perform one epoch of training, we need to go through the following steps:
Step 1: Select the records o1 - o4 for training. These records have the following input and output values:
o1: (a1=0.5, a2=0, a3=0.2, C=1)
o2: (a1=0, a2=0.3, a3=0, C=1)
o3: (a1=0.4, a2=0.1, a3=0.5, C=0)
o4: (a1=0.3, a2=0.2, a3=0.2, C=1)
Step 2: Initialize the weights and biases according to the given values:
w14 = w15 = w24 = w25 = w34 = 0.5
w35 = w46 = w56 = 0.5
B4 = B5 = B6 = 0.5
Step 3: Set the learning rate to lr = 0.2
Step 4: For each training record, do the following:
User
Perform testing your trained network with records o5 − o6 - specify your criteria of correct/incorrect classification of test records
Use your ONE EPOCH Basic Model (classifier) to classify a record (0, 0.1, 0.2) - write down your criteria of all decisions used in the process
Assistant
To test the trained network with records o5 and o6, we can follow the same procedure as in Step 4 of the training process:
For o5:
Calculate the net input of the hidden layer nodes:
net4 = w14 * 0.1 + w24 * 0 + w34 * 0.4 + B4
net5 = w15 * 0.1 + w25 * 0 + w35 * 0.4 + B5
Apply the sigmoid activation function to the net input of the hidden layer nodes to get their output values:
out4 = 1 / (1 + e^(-net4))
out5 = 1 / (1 + e^(-net5))
Calculate the net input of the output layer node:
net6 = w46 * out4 + w56 * out5 + B6
Apply the sigmoid activation function to the net input of the output layer node to get its output value:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
In this case, we have three input features (a1, a2, and a3) and two output classes (C=0 or C=1). Therefore, the input layer will have three nodes (1, 2, and 3), and the output layer will have two nodes (5 and 6).
Step 2: Choose the number of hidden layers and nodes
We are asked to use only one hidden layer with 2 nodes.
Step 3: Define the weights and biases
To define the weights and biases, we can use random initialization. Let's assume the following initial values for the weights and biases:
The bias of the hidden layer node 4 is -0.4
The bias of the hidden layer node 5 is 0.2
The bias of the output layer node 6 is -0.3
The weight of the input feature a1 to the hidden layer node 4 is 0.2
The weight of the input feature a2 to the hidden layer node 4 is 0.1
The weight of the input feature a3 to the hidden layer node 4 is -0.3
The weight of the input feature a1 to the hidden layer node 5 is -0.1
The weight of the input feature a2 to the hidden layer node 5 is 0.4
The weight of the input feature a3 to the hidden layer node 5 is -0.2
The weight of the hidden layer node 4 to the output layer node 6 is 0.1
The weight of the hidden layer node 5 to the output layer node 6 is 0.3
Step 4: Define the activation function
We can use the sigmoid activation function for both the hidden and output layers.
With the above information, we can draw the full classification neural network as follows:
a1 (1) a2 (2) a3 (3)
| | |
| | |
V V V
w1=0.2 w2=0.1 w3=-0.3
(4) -------------- ---------------> (6)
/ \ \
/ \ \
w4=-0.1 w5=0.4 w6=0.3
/ \ \
| | |
| | |
V V V
(1) (2) (5)
where:
a1, a2, and a3 are the input features
(1) and (2) are the input nodes
(4) and (5) are the hidden nodes
(6) is the output node
w1 to w6 are the weights
the biases of the hidden layer nodes (4 and 5) and the output layer node (6) are -0.4, 0.2, and -0.3, respectively.
Note: the sigmoid activation function is used in nodes (4), (5), and (6).
Calculate the net input of the hidden layer nodes:
net4 = w14 * a1 + w24 * a2 + w34 * a3 + B4
net5 = w15 * a1 + w25 * a2 + w35 * a3 + B5
Apply the sigmoid activation function to the net input of the hidden layer nodes to get their output values:
out4 = 1 / (1 + e^(-net4))
out5 = 1 / (1 + e^(-net5))
Calculate the net input of the output layer node:
net6 = w46 * out4 + w56 * out5 + B6
Apply the sigmoid activation function to the net input of the output layer node to get its output value:
out6 = 1 / (1 + e^(-net6))
Calculate the error of the output layer node:
error6 = (C - out6) * out6 * (1 - out6)
Calculate the error of the hidden layer nodes:
error4 = out4 * (1 - out4) * w46 * error6
error5 = out5 * (1 - out5) * w56 * error6
Update the weights and biases:
w46 = w46 + lr * error6 * out4
w56 = w56 + lr * error6 * out5
B6 = B6 + lr * error6
w14 = w14 + lr * error4 * a1
w24 = w24 + lr * error4 * a2
w34 = w34 + lr * error4 * a3
B4 = B4 + lr * error4
w15 = w15 + lr * error5 * a1
w25 = w25 + lr * error5 * a2
w35 = w35 + lr * error5 * a3
B5 = B5 + lr * error5
Step 5: After training with all records, we can evaluate the performance of the model using the remaining records o5 and o6.
Note: We assumed that the sigmoid activation function is used in nodes (4), (5), and (6) as stated in the problem description.
out6 = 1 / (1 + e^(-net6))
Since the output value is greater than or equal to 0.5, we classify o5 as belonging to class 1.
For o6:
Calculate the net input of the hidden layer nodes:
net4 = w14 * 0.4 + w24 * 0.3 + w34 * 0.2 + B4
net5 = w15 * 0.4 + w25 * 0.3 + w35 * 0.2 + B5
Apply the sigmoid activation function to the net input of the hidden layer nodes to get their output values:
out4 = 1 / (1 + e^(-net4))
out5 = 1 / (1 + e^(-net5))
Calculate the net input of the output layer node:
net6 = w46 * out4 + w56 * out5 + B6
Apply the sigmoid activation function to the net input of the output layer node to get its output value:
out6 = 1 / (1 + e^(-net6))
Since the output value is less than 0.5, we classify o6 as belonging to class 0.
The criteria for correct classification is to compare the predicted class with the actual class of the record. If they match, then the classification is correct; otherwise, it is incorrect.
To classify a record (0, 0.1, 0.2), we can follow the same procedure as above, using the weights and biases obtained after one epoch of training. The net input, output, and classification will depend on the values of the weights and biases, as well as the input values.