Commit f8e2933e authored by Yipeng Hu's avatar Yipeng Hu

ref #5 GPU version tested

parent d9bff132
......@@ -5,12 +5,11 @@ import numpy as np
import random
import os
import matplotlib.pyplot as plt
# https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/segmentation.ipynb
# https://becominghuman.ai/image-classification-with-tensorflow-2-0-without-keras-e6534adddab2
# https://colab.research.google.com/drive/1i-7Vn_9hGdOvMjkYNedK5nsonNizhe0o#scrollTo=z3w4D1V0SkZ8&forceEdit=true&sandboxMode=true
os.environ["CUDA_VISIBLE_DEVICES"]="0"
### Define a few functions for network layers
def conv3d(input, filters, downsample=False, activation=True, batch_norm=False):
......@@ -167,7 +166,7 @@ def batch_norm(inputs, is_training, decay = 0.999):
### training
learning_rate = 1e-3
learning_rate = 1e-5
optimizer = tf.optimizers.Adam(learning_rate)
def loss_crossentropy(pred, target):
......@@ -232,11 +231,11 @@ for step in range(total_iter):
optimizer.apply_gradients(zip(gradients, var_list))
# print training information
if (step % 1) == 0:
if (step % 100) == 0:
print('Step %d: training-loss=%f' % (step, loss_train))
# --- simple tests during training ---
if (step % 50) == 0:
if (step % 1000) == 0:
indices_test = [random.randrange(30) for i in range(size_minibatch)] # select size_minibatch test data
input_test = DataFeeder.load_images_test(indices_test)[:, ::2, ::2, ::2, :]
pred_test = residual_unet(input_test)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment