0
$\begingroup$

Just starting learning things about tensorflow and NN. As an exercise I decided to create a dataset of images, watermarked and not, in order to binary classify these. First of all, the dataset ( you can see it here ) was created artificially by me applying some random watermarks. First doubt, in the dataset I don't have both images one watermarked and one not, would be better to have? Second, frustrating: model stand on 0.5 accuracy, so it just produce random output :( Model I tried is this:

model = tf.keras.Sequential([
    tf.keras.layers.Conv2D(16,(1,1), activation='relu', input_shape=(150, 150, 3)),
    tf.keras.layers.MaxPool2D(2,2),
    tf.keras.layers.Conv2D(32,(3,3), activation='relu'),
    tf.keras.layers.MaxPool2D(2,2),
    tf.keras.layers.Conv2D(64,(3,3), activation='relu'),
    tf.keras.layers.MaxPool2D(2,2),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(128, activation='elu'),
    tf.keras.layers.Dense(64, activation='elu'),
    tf.keras.layers.Dense(32, activation='relu'),
    tf.keras.layers.Dense(1,activation="sigmoid")

and then compiled as this:

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

Here below the fit:

history = model.fit(train_data,
                              validation_data=valid_data,
                              steps_per_epoch=100,
                              epochs=15,
                              validation_steps=50,
                              verbose=2)

As for any other details, code is here. I already checked for technical issues, I'm pretty sure image enter properly, train and validation dataset are 80/20, about 12K images for training. However accuracy bounches up and down around .5 while fitting. How can I improve?

$\endgroup$
0
$\begingroup$

Well probably the response is that previous approach was a little naive. I managed to fave some interesting result with this kernel that allow me to have an accuracy of 0.969 and a validation accuracy of 0.931. Model I used is based on ResNet50 with the following additional layers ( and the last one just for binary classification ):

tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(1,activation="sigmoid")

Even if the net is already trained, I trained each layer again otherwise I did not have any sensible accuracy.

Training history is like this:

enter image description here

Still far to be really good, but progress.

| improve this answer | |
$\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.