in Education by
I have a simple NN model for detecting hand-written digits from a 28x28px image written in python using Keras: model0 = Sequential() #number of epochs to train for nb_epoch = 12 #amount of data each iteration in an epoch sees batch_size = 128 model0.add(Flatten(input_shape=(1, img_rows, img_cols))) model0.add(Dense(nb_classes)) model0.add(Activation('softmax')) model0.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy']) model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch, verbose=1, validation_data=(X_test, Y_test)) score = model0.evaluate(X_test, Y_test, verbose=0) print('Test score:', score[0]) print('Test accuracy:', score[1]) This runs well and I get ~90% accuracy. I then perform the following command to get a summary of my network's structure by doing print(model0.summary()). This outputs the following: Layer (type) Output Shape Param # Connected to ===================================================================== flatten_1 (Flatten) (None, 784) 0 flatten_input_1[0][0] dense_1 (Dense) (None, 10) 7850 flatten_1[0][0] activation_1 (None, 10) 0 dense_1[0][0] ====================================================================== Total params: 7850 I don't understand how they get to 7850 total params and what that actually means? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
In the neural networks, every hidden unit has some input weight and some additional weight of connection with bias. The number of parameters in your problem is 7850 because with every hidden unit you have 784 input weights and one weight of connection with bias. This means that every hidden unit gives you 785 parameters. You have 10 units so it sums up to 7850. The role of this additional bias term is really important. It significantly increases the capacity of your model.

Related questions

0 votes
    I have trouble understanding the difference (if there is one) between roc_auc_score() and auc() in scikit-learn. I ... out why. Thanks! Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    What is the role of Flatten in Keras. I am executing the code below and it's a two layered network. The ... output is already flat? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    Every time I use binary_crossentropy there's ~80% acc and when I use categorical_crossentrop there's ~50% acc. And I ... should I use? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to save the history to a file, in Keras I have model.fit history = model.fit(Q_train, W_train, ... =(Q_test, W_test)) Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    Is there a simple way to find the number of parameters of a keras model if I have CNN, LSTm etc. Just like we do it in FFN. Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I'm Working on document classification tasks in java. Both algorithms came highly recommended, what are the ... Processing tasks? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I just started with machine learning. I want to know about the applications of machine learning. I know we ... recent applications. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I'm learning the difference between the various machine learning algorithms. I understand that the implementations of ... for that? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I am training on 970 samples and validating on 243 samples. How big should batch size and number of epochs be ... on data input size? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    If I want to use the BatchNormalization function in Keras, then do I need to call it once only at the ... much of a difference. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    For any Keras layer (Layer class), can someone explain how to understand the difference between input_shape, units, ... image below? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I've trained a sentiment classifier model using Keras library by following the below steps(broadly). Convert Text ... around this? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    Currently, I have Keras with TensorFlow and CUDA at the backend. But, I want to force Keras to use the ... are accessible via Keras. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I am working on the following code: model = Sequential() a = keras.layers.advanced_activations.PReLU(init='zero', ... solution to this? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    In the MNIST beginner tutorial, there is the statement accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) tf ... (x,1)? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...