Trying to create a fully connected neural network for CIFAR-10

user278039

I am a relative beginner when it comes to machine learning.

I have been playing with Keras with TensorFlow as a backend and for some reason I am not getting good accuracy when I am using the CIFAR-10 dataset.

This is my code.

model = Sequential()

batch_size = 250

model.add(Dense(100, input_shape = (3072, ), activation='relu',
bias_initializer = 'RandomNormal',kernel_regularizer=regularizers.l2(.01)))


model.add(Dense(50))

model.add(Dense(10))

model.compile(optimizer=keras.optimizers.SGD(lr=0.004), 
loss='hinge', metrics=['categorical_accuracy'])

model.fit(x=X_train, y=utils.to_categorical(Y_Train, num_classes = 10), 
batch_size = batch_size, epochs = 100, validation_split = .4)

X_Train is a (50000, 3072) numpy array and Y_Train is a (50000, 1) numpy array.

The result I got was

loss: 1.1865

categorical_accuracy: 0.1696

val_loss: 1.1859

val_categorical_accuracy: 0.1668

in 100 epochs.

My setup is Ubuntu 18.04, Python 3.6, Numpy 1.16, Keras 2.2.4

Is there something wrong in my code or is it the fact that a fully connected neural network is just a bad setup for image classification and one should use a convolution neural network?

Omegastick

There are a number of issues with your model:

  • Layers 2 and 3 have no activation, and are thus linear (useless for classification, in this case)

  • Specifically, you need a softmax activation on your last layer. The loss won't know what to do with linear output.

  • You use hinge loss, when you should be using something like categorical_crossentropy.

What Jibin said about your fully connected model not being complex enough is not true, you don't need much complexity to get decent accuracy on CIFAR10.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Trying to create a convolutional neural Autoencoder network in Keras but it keeps crashing

分類Dev

TypeError when trying to create a BLSTM network in Keras

分類Dev

Trying to understand neural networks

分類Dev

Neural Network: Solving XOR

分類Dev

FizzBuzz Neural Network

分類Dev

Retrain of a neural network

分類Dev

Inconsistent Neural Network output

分類Dev

Weights in Neural Network

分類Dev

Neural network for optimization problems

分類Dev

Stabilizing Neural Network

分類Dev

Keras overfits on one class Cifar-10

分類Dev

PyTorch convolutional block - CIFAR10 - RuntimeError

分類Dev

Fully Convolutional Network Receptive Field

分類Dev

Trouble understanding Convolutional Neural Network

分類Dev

Issue in bootstrapping a neural network in r

分類Dev

Resume training convolutional neural network

分類Dev

Tensorflow Neural network loss not decreasing

分類Dev

Exporting Outputs from a Neural Network

分類Dev

neural network with mostly zero target

分類Dev

Denormalization of output from neural network

分類Dev

Deep Neural Network Not Learning Anything

分類Dev

Implementing a neural network in C#

分類Dev

Blocking acess if are not connected to a determined network

分類Dev

torchvision.datasets.cifar.CIFAR10はリストですか?

分類Dev

How to fully reset network settings on 18.04?

分類Dev

how to shape tensor from fully connected to to 4-D

分類Dev

Tensorflow 2のtf.contrib.layers.fully_connected()?

分類Dev

How does a (2 or 3) dimensional Fully connected layer work?

分類Dev

TensorflowArgumentError実行中のCIFAR-10の例