Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import numpy as np import csv as csv text_file = open( optdigits_train.txt , r ) line = text_file.readlines() f = open( optdigits_test.txt , r )

import numpy as np import csv as csv text_file = open("optdigits_train.txt", "r") line = text_file.readlines() f = open("optdigits_test.txt","r") test = f.readline() x =np.array(line) y =np.array(test) def sigmoid (x): return 1/(1 + np.exp(-x)) #Derivative of Sigmoid Function def derivatives_sigmoid(x): return x * (1 - x) #Variable initialization epoch=3000000 #Setting training iterations lr=0.1 #Setting learning rate inputlayer_neurons = x.shape(300000) #number of features in data set hiddenlayer_neurons = 2 #number of hidden layers neurons output_neurons = 100 #number of neurons at output layer  #weight and bias initialization wh=np.random.uniform(size=(inputlayer_neurons,hiddenlayer_neurons)) bh=np.random.uniform(size=(1,hiddenlayer_neurons)) wout=np.random.uniform(size=(hiddenlayer_neurons,output_neurons)) bout=np.random.uniform(size=(1,output_neurons)) for i in range(epoch): hidden_layer_input1=np.dot(X,wh) hidden_layer_input=hidden_layer_input1 + bh hiddenlayer_activations = sigmoid(hidden_layer_input) output_layer_input1=np.dot(hiddenlayer_activations,wout) output_layer_input= output_layer_input1+ bout output = sigmoid(output_layer_input) #Backpropagation E = y-output slope_output_layer = derivatives_sigmoid(output) slope_hidden_layer = derivatives_sigmoid(hiddenlayer_activations) d_output = E * slope_output_layer Error_at_hidden_layer = d_output.dot(wout.T) d_hiddenlayer = Error_at_hidden_layer * slope_hidden_layer wout += hiddenlayer_activations.T.dot(d_output) *lr bout += np.sum(d_output, axis=0,keepdims=True) *lr wh += X.T.dot(d_hiddenlayer) *lr bh += np.sum(d_hiddenlayer, axis=0,keepdims=True) *lr print (output) 

file have all numberical values and is needed to train ANN then test.

This is my code and im trying to build a nurel network .. haivng issue with code saying tuple object is not callable.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

5. Identify strategies for building coalitions across cultures.

Answered: 1 week ago

Question

"Is global warming " a fact? Can you please provide two websites

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago