0
$\begingroup$

Since I'm new in deep learning I have some questions. I made some tests with keras and mnist dataset and everything was OK.

Then I decided to try with some of my datests. You could find the dataset here: dataset. I'm not sure if uploading dataset on such service is OK for the community. The model is simple classifier and the target property is at position 0 in the dataset.

The thing that worries me is that the model is build quite fast - about 1 second per epoch. I'm not sure if I read my data correctly and I need an advice for the model that I made.

So thanks in advance for the time you spare to help me.

Here is the code that I used:

from numpy import zeros as zero

from keras.models import Sequential
from keras.layers import Dense, Dropout

import tensorflow as tf

f_train = open("train.csv", "r")

train_data_x = zero((10764, 512))
train_data_y = zero((10764, 1))

n=0
for line in f_train.readlines():
    line = line[:-1]
    train_data_x[n]= line.split(",")[1:]
    train_data_y[n] = line.split(",")[0]
    n+=1

f_test = open("test.csv", "r")

test_data_x = zero((7177, 512))
test_data_y = zero((7177, 1))

n=0
for line in f_test.readlines():
    line = line[:-1]
    test_data_x[n]= line.split(",")[1:]
    test_data_y[n] = line.split(",")[0]
    n+=1

model = Sequential()
model.add(Dense(256, input_dim=512, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))

model.compile(loss="binary_crossentropy", optimizer="adam", metrics=["accuracy"])

model.fit(train_data_x, train_data_y, epochs=20, batch_size=128, validation_split=0.25, verbose=2)
test_loss, test_acc = model.evaluate(test_data_x, test_data_y, batch_size=128,verbose=0)
print(f"test_loss: {test_loss}; test_acc: {test_acc}")

Edit: Reupload dataset

$\endgroup$
1
$\begingroup$

Speed wouldn’t be a reason for concern as you should look at accuracy. However if you believe there is overfitting going on, you may want to try and lowering down the batch size. It will make your speed slower and will make it even harder to overfit(even with your dropout layers). Also, try adding in more dense layers between the dropouts. Typically we would see dropouts at the beginning of a fully connected NN. Since your network is short, having too many dropouts would not necessarily be a good thing.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.