def build_model(input_data_tensor, input_label_tensor): num_classes = config["num_classes"] images = tf.image.resize_images(input_data_tensor, [224, 224]) logits = vgg.build(images, n_classes=num_classes, training=True) probs = tf.nn.softmax(logits) loss = L.loss(logits, tf.one_hot(input_label_tensor, num_classes)) error_top5 = L.topK_error(probs, input_label_tensor, K=5) error_top1 = L.topK_error(probs, input_label_tensor, K=1) # you must return a dictionary with at least the "loss" as a key return dict(loss=loss, logits=logits, error_top5=error_top5, error_top1=error_top1)
def build_model(input_data_tensor, input_label_tensor): num_classes = config["num_classes"] weight_decay = config["weight_decay"] images = tf.image.resize_images(input_data_tensor, [224, 224]) logits = vgg.build(images, n_classes=num_classes, training=True) probs = tf.nn.softmax(logits) loss_classify = L.loss(logits, tf.one_hot(input_label_tensor, num_classes)) loss_weight_decay = tf.reduce_sum(tf.stack([tf.nn.l2_loss(i) for i in tf.get_collection('variables')])) loss = loss_classify + weight_decay*loss_weight_decay error_top5 = L.topK_error(probs, input_label_tensor, K=5) error_top1 = L.topK_error(probs, input_label_tensor, K=1) # you must return a dictionary with loss as a key, other variables return dict(loss=loss, probs=probs, logits=logits, error_top5=error_top5, error_top1=error_top1)