Revision e1467a79dc6580ae009d827b5e6f274faff3b339 authored by liqunfu on 27 March 2020, 21:42:04 UTC, committed by GitHub on 27 March 2020, 21:42:04 UTC
support Pooling ops with Sequence axis
ResNet18_ImageNet1K.cntk
# Node: ResNet-18 with ImageNet -- 18 layers plain ResNet for image classification
# Reference: "Deep Residual Learning for Image Recognition" https://arxiv.org/abs/1512.03385
command = TrainNetwork:Eval
precision = "float"; traceLevel = 1; deviceId = "auto"
RootDir = "."
ConfigDir = "$RootDir$"
DataDir = "$RootDir$"
OutputDir = "$RootDir$/Output"
ModelDir = "$OutputDir$/Models"
MeanDir = "$DataDir$"
modelPath = "$ModelDir$/ResNet_18"
stderr = "$OutputDir$/ResNet_18_BS_out"
parallelTrain = true
TrainNetwork = {
action = "train"
BrainScriptNetworkBuilder = {
include "$ConfigDir$/Macros.bs"
imageShape = 224:224:3 # image dimensions
labelDim = 1000 # number of distinct labels
cMap = 64:128:256:512
bnTimeConst = 4096
model = Sequential(
# conv1 and max pooling
ConvBNReLULayer {cMap[0], (7:7), (2:2), bnTimeConst} :
MaxPoolingLayer {(3:3), stride = 2, pad = true} :
ResNetBasicStack {2, cMap[0], bnTimeConst} :
ResNetBasicInc {cMap[1], (2:2), bnTimeConst} :
ResNetBasic {cMap[1], bnTimeConst} :
ResNetBasicInc {cMap[2], (2:2), bnTimeConst} :
ResNetBasic {cMap[2], bnTimeConst} :
ResNetBasicInc {cMap[3], (2:2), bnTimeConst} :
ResNetBasicStack {2, cMap[3], bnTimeConst} :
# avg pooling
AveragePoolingLayer {(7: 7), stride = 1} :
# FC
LinearLayer {labelDim, init = 'normal', initValueScale = 0.01}
)
# inputs
features = Input {imageShape}
labels = Input {labelDim}
# apply model to features
z = model (features)
# loss and error computation
ce = CrossEntropyWithSoftmax (labels, z)
errs = ClassificationError (labels, z)
top5Errs = ClassificationError (labels, z, topN = 5)
# declare special nodes
featureNodes = (features)
labelNodes = (labels)
criterionNodes = (ce)
evaluationNodes = (errs : top5Errs)
outputNodes = (z)
}
SGD = {
epochSize = 0
minibatchSize = 256
maxEpochs = 90
learningRatesPerMB = 1*30: 0.1*30: 0.01*20: 0.001
momentumPerMB = 0.9
useNAG = true # use Nesterov Momentum
gradUpdateType = "None"
L2RegWeight = 0.0001
dropoutRate = 0
numMBsToShowResult = 100
disableRegInBatchNormalization = true
ParallelTrain = {
parallelizationMethod = "DataParallelSGD"
distributedMBReading = true
parallelizationStartEpoch = 1
DataParallelSGD = {
gradientBits = 32
}
}
}
reader = {
readerType = "ImageReader"
file = "$DataDir$/train_map.txt"
randomize = "Auto"
features = {
width = 224
height = 224
channels = 3
cropType = "RandomArea"
jitterType = "UniRatio"
areaRatio = 0.08:1.0
aspectRatio = 0.75:1.3333
interpolations = "cubic"
brightnessRadius = 0.4
contrastRadius = 0.4
saturationRadius = 0.4
hflip = true
meanFile = "$MeanDir$/ImageNet1K_mean.xml"
}
labels = {
labelDim = 1000
}
}
cvReader = {
readerType = "ImageReader"
file = "$DataDir$/val_map.txt"
randomize = "None"
features = {
width = 224
height = 224
channels = 3
cropType = "Center"
sideRatio = 0.875
interpolations = "cubic"
meanFile = "$MeanDir$/ImageNet1K_mean.xml"
}
labels = {
labelDim = 1000
}
}
}
Eval = {
action = "test"
modelPath = "$modelPath$"
minibatchSize = 200
evalNodeNames = errs:top5Errs
reader={
readerType = "ImageReader"
file = "$DataDir$/val_map.txt"
randomize = "None"
features = {
width = 224
height = 224
channels = 3
cropType = "Center"
sideRatio = 0.875
interpolations = "cubic"
meanFile = "$MeanDir$/ImageNet1K_mean.xml"
}
labels = {
labelDim = 1000
}
}
}
Computing file changes ...