This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def train(net, train_iter, val_iter, batch_size, epochs, ctx): | |
learning_rate = 0.01 | |
wd = 0.002 | |
log_interval=100 | |
if isinstance(ctx, mx.Context): | |
ctx = [ctx] | |
trainer = gluon.Trainer(net.collect_params(), 'adam', | |
{'learning_rate': learning_rate}) | |
loss = gluon.loss.SigmoidBinaryCrossEntropyLoss() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
____________________________________________________________________________________________________ | |
convolution2d_134 (Convolution2D (None, 2, 64, 80) 66 convolution2d_133[0][0] | |
____________________________________________________________________________________________________ | |
permute_5 (Permute) (None, 64, 80, 2) 0 convolution2d_134[0][0] | |
____________________________________________________________________________________________________ | |
reshape_7 (Reshape) (None, 5120, 2) 0 permute_5[0][0] | |
____________________________________________________________________________________________________ | |
activation_6 (Activation) (None, 5120, 2) 0 reshape_7[0][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_author__ = 'Fabian Isensee' | |
from collections import OrderedDict | |
from lasagne.layers import InputLayer, ConcatLayer, Pool2DLayer, ReshapeLayer, DimshuffleLayer, NonlinearityLayer, DropoutLayer, Upscale2DLayer, Upscale3DLayer, BatchNormLayer, batch_norm | |
from lasagne.layers.dnn import Conv3DDNNLayer as ConvLayer, Pool3DDNNLayer as PoolLayer | |
import lasagne | |
from lasagne.init import HeNormal | |
def build_UNet(n_input_channels=1, BATCH_SIZE=None, num_output_classes=2, pad='same', nonlinearity=lasagne.nonlinearities.elu, input_dim=(128, 128), depth=32, base_n_filters=32, kernel_size=3, do_dropout=False): | |
net = OrderedDict() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#to_categorical() acquired from Keras implementation | |
#dice_coef() inspired by Marco Jocic's implementation: https://github.com/jocicmarko/ultrasound-nerve-segmentation/blob/master/train.py | |
def to_categorical(y, nb_classes=None): | |
"""Converts a class vector (integers) to binary class matrix. | |
E.g. for use with categorical_crossentropy. | |
# Arguments | |
y: class vector to be converted into a matrix | |
(integers from 0 to nb_classes). |
NewerOlder