Im a begginer at machine learning stuff, but i was designed to implement a machine learning model based on a paper i’ve read.
This paper implements a multi-task learning model for attribute classification (labelled images are the model input, by labelled i mean attributes anotations, 40 for each image).
It is a multi-task learning model beacuse there is a shared dense layer right after the model input layer and 40 attribute branchs, each one of them with their own loss function (binary cross-entropy for all of them) and own sigmoid activation function (on the last layer, to predict if each one of the 40 attributes are or not at the image).
After a lot of hard work it finally started returning probabilities on all sigmoid function on all branchs, but the probabilities only of val_accuracy were wrong: The val_loss and the loss (training loss) were getting smaller and smaller, and the acc (training accuracy) was also in a normal range of probabilities values, except for the val_accuracy wich were always the same value or it complement.
For example (5 epochs just for example):
The Accuracy for one attribute prediction at one of the 40 branchs:
5_o_Clock_Shadow_Accuracy
0 0.823665
1 0.891178
2 0.891178
3 0.891178
The loss for the same attribute:
5_o_Clock_Shadow_loss
0 0.921046
1 0.701494
2 0.913597
3 0.765397
4 0.894950
The val_loss:
val_5_o_Clock_Shadow_loss
0 730232.750000
1 300412.500000
2 376215.843750
3 0.747685
4 1.607191
And finally the val_Accuracy:
val_5_o_Clock_Shadow_Accuracy
0 0.882382
1 0.117618
2 0.882382
3 0.882382
4 0.882382
My model:
def subnet(shared_layers_output, i):
att_branch = Dense(512, name='dense_'+str(i)+'_1')(shared_layers_output)
att_branch = ReLU()(att_branch)
att_branch = BatchNormalization()(att_branch)
att_branch = Dropout(0.5)(att_branch)
att_branch = Dense(512, name='dense_'+str(i)+'_2')(att_branch)
att_branch = ReLU()(att_branch)
att_branch = BatchNormalization()(att_branch)
att_branch = Dropout(0.5)(att_branch)
branch_output = Dense(1, name=att_list[i], activation='sigmoid')(att_branch)
return branch_output
def multi_task_model():
#Input
input_layer = Input(shape=(512,), name='input_layer')
#Camada compartilhada (1 única)
shared_x = Dense(512, name='shared_dense_layer')(input_layer)
shared_x = ReLU()(shared_x)
shared_x = BatchNormalization()(shared_x)
shared_x = Dropout(0.5)(shared_x)
branch_outputs = list()
for i in range(40):
branch_outputs.append(subnet(shared_x, i))
model = Model(input_layer, branch_outputs, name='model')
return model
Train and test input shape: (n_samples, 512)
Train and test labels input shape: (40, n_samples)
Learning rate: 1e-03
Thats it, any help would be appreciated, thanks in advance.