Пример #1
0
    logging.info(f"Starting epoche {e}")

    # =====================================================
    # Training step
    logging.info("Start train")
    for it, (imgs, labels) in enumerate(pipeTrain.ds.take(subitsTrain)):

        # Calculate current global step
        step = e * subitsTrain + it

        # Prepartion for cafe models:
        imgsCaf = 255 * imgs - tf.constant([123.68, 116.779, 103.939])

        # Do one training step
        loss, logits = classy.trainStep(imgsCaf, labels)

        # Calculate accuracy
        accTrain.update_state(tf.math.argmax(logits, axis=-1),
                              tf.math.argmax(labels, axis=-1))

        # Write to Tensorboard
        with trainSummaryWriter.as_default():
            tf.summary.scalar('loss', loss, step=step)
            tf.summary.scalar('accuracy', accTrain.result().numpy(), step=step)

        # Logging images
        if step % logImagesIt == 0:

            logging.info("Logging images")