tensorflow - Regarding setting up the target tensor shape for sparse_categorical_crossentropy -
i trying experiment multi-layer encoder-decoder type of network. screenshot of last several layers of network architecture follows. how setup model compiling , training process.
optimizer = sgd(lr=0.001, momentum=0.9, decay=0.0005, nesterov=false) autoencoder.compile(loss="sparse_categorical_crossentropy", optimizer=optimizer, metrics=['accuracy']) model.fit(imgs_train, imgs_mask_train, batch_size=batch_size, nb_epoch=nb_epoch, verbose=1,callbacks=[model_checkpoint])
imgs_train
, imgs_mask_train
of shape (2000, 1, 128, 128)
. imgs_train
represent raw image , imgs_mask_train
represents mask image. trying solve semantic segmentation problem. however, running program generates following error message, (i keep main related part).
tensorflow.python.pywrap_tensorflow.statusnotok: invalid argument: logits first dimension must match labels size. logits shape=[4096,128] labels shape=[524288] [[node: sparsesoftmaxcrossentropywithlogits = sparsesoftmaxcrossentropywithlogits[t=dt_float, tlabels=dt_int64, _device="/job:localhost/replica:0/task:0/cpu:0"](reshape_364, cast_158)]]
it seems me loss function of sparse_categorical_crossentropy
causes problem current (imgs_train, imgs_mask_train) shape setting. keras api not include detail how setup target tensor. suggestions highly appreciated!
i trying figure same problem , far can tell takes sparse representation of target category. means integers target label instead of one-hot encoded binary class matrix.
concerning problem, have categories in masking or have information outline of object? outline information becomes pixel wise binary loss instead of categorical one. if have categories, output of decoder should have dimensionality (none, number_of_classes, 128, 128). on should able use sparse target mask haven't tried myself... hope helps
Comments
Post a Comment