def resBlockStride(preAct, resParams, train, bn_updates, BA, GAselect): snrg = RandomStreams(12345) current_params = resParams[0] inAct, newRM, newRV = layers.convStrideBNAct(preAct, current_params[:6], train) bn_updates.append((current_params[4], newRM)) bn_updates.append((current_params[5], newRV)) inAct = STEquant(inAct, BA) if GAselect == 8: inAct = quantizeGrad.quantizeGradL8(inAct) elif GAselect == 14: inAct = quantizeGrad.quantizeGradL14(inAct) inAct = layers.dropout(inAct, train, 0.8, snrg) current_params = resParams[1] outAct, newRM, newRV = layers.convBN(inAct, current_params[:6], train) bn_updates.append((current_params[4], newRM)) bn_updates.append((current_params[5], newRV)) current_params = resParams[2] shortCut, newRM, newRV = layers.convStrideBN(preAct, current_params[:6], train) bn_updates.append((current_params[4], newRM)) bn_updates.append((current_params[5], newRV)) outAct = layers.slopedClipping(outAct + shortCut) return outAct, bn_updates
def resBlockStride(preAct, resParams, train): resActivations = [] current_params = resParams[0] inAct, _, _ = layers.convStrideBNAct(preAct, current_params, train) resActivations.append(inAct) current_params = resParams[1] outAct, _, _ = layers.convBN(inAct, current_params, train) current_params = resParams[2] shortCut, _, _ = layers.convStrideBN(preAct, current_params, train) outAct = layers.slopedClipping(outAct + shortCut) resActivations.append(outAct) return outAct, resActivations
def resBlockStride(preAct, resParams, train, BA1, BA2, BW1, BW2, BW3): current_params = resParams[0] current_params[0] = layers.quantizeWeight(current_params[0], BW1) inAct, _, _ = layers.convStrideBNAct(preAct, current_params, train) inAct = 0.8 * inAct current_params = resParams[1] current_params[0] = layers.quantizeWeight(current_params[0], BW2) outAct, _, _ = layers.convBN(inAct, current_params, train) current_params = resParams[2] current_params[0] = layers.quantizeWeight(current_params[0], BW3) shortCut, _, _ = layers.convStrideBN(preAct, current_params, train) outAct = layers.slopedClipping(outAct + shortCut) return outAct
def resBlockStride(preAct, resParams, train, bn_updates): snrg = RandomStreams(12345) resActivations = [] current_params = resParams[0] inAct, newRM, newRV = layers.convStrideBNAct(preAct, current_params, train) resActivations.append(inAct) bn_updates.append((current_params[4], newRM)) bn_updates.append((current_params[5], newRV)) inAct = layers.dropout(inAct, train, 0.8, snrg) current_params = resParams[1] outAct, newRM, newRV = layers.convBN(inAct, current_params, train) bn_updates.append((current_params[4], newRM)) bn_updates.append((current_params[5], newRV)) current_params = resParams[2] shortCut, newRM, newRV = layers.convStrideBN(preAct, current_params, train) bn_updates.append((current_params[4], newRM)) bn_updates.append((current_params[5], newRV)) outAct = layers.slopedClipping(outAct + shortCut) resActivations.append(outAct) return outAct, resActivations, bn_updates