# read dataset dataset = Dataset("training-1.csv") # create column features for further fit them into a model dataset.create_feature_columns() # preprocess it dataset.preprocess() #split on train/test dataset.split_data() # initialize model model = MyModel() # build it model.build(dataset.feature_columns) # train model.train(dataset.train_ds, dataset.val_ds) # evaluate model.evaluate(dataset.test_ds)
# lr ExponentialDecay lr_schedule = tf.keras.optimizers.schedules.ExponentialDecay( config['learning_rate'], decay_steps=config['decay_steps'], decay_rate=config['decay_rate']) model.compile( optimizer=tf.keras.optimizers.Adam(learning_rate=lr_schedule), loss=Loss(), metrics=[PSNR(), SSIM()], ) # resume checkpoint if config['resume']: model.build((None, None, None, 3)) model.load_weights(checkpoint_path) # save the best model checkpoint model_checkpoint_callback = tf.keras.callbacks.ModelCheckpoint( filepath=checkpoint_path, save_weights_only=True, monitor='val_loss', mode='min', save_best_only=True) # tensorboard visulization tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1) # model fit
# This are **roughly** the KITTI camera parameters. But they are not precise, and # they are not even the same on all sequences!! fx = 720.0 fy = 720.0 cx = 608.0 cy = 180.0 # I've downsampled the images, so: fx /= 1.725 fy /= 1.67 cx /= 1.725 cy /= 1.67 model = MyModel(fx, fy, cx, cy) model.build((None, 224, 720, 6)) model.summary() if restore_path: model.load_weights(restore_path) train_loss = tf.keras.metrics.Mean(name='train_loss') optimizer = tf.keras.optimizers.Adam(learning_rate=1e-3) # optimizer = tf.keras.optimizers.Adam(learning_rate=1e-4) current_time = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") log_dir = 'logs/' + current_time summary_writer = tf.summary.create_file_writer(log_dir) # save_path = 'checkpoints\\run_' + current_time