r"""BNInception model architecture from <https://arxiv.org/pdf/1502.03167.pdf>`_ paper.
343922
def bninception(num_classes=1000, pretrained='imagenet'):
    
    """
    model = BNInception(num_classes=num_classes)
    if pretrained is not None:
        settings = pretrained_settings['bninception'][pretrained]
        assert num_classes == settings['num_classes'], \
            "num_classes should be {}, but is {}".format(settings['num_classes'], num_classes)
        model.load_state_dict(model_zoo.load_url(settings['url']))
        model.input_space = settings['input_space']
        model.input_size = settings['input_size']
        model.input_range = settings['input_range']
        model.mean = settings['mean']
        model.std = settings['std']
    return model
1044612
def get_risk_models(oqparam, kind='vulnerability vulnerability_retrofitted '
                    'fragility consequence'):
    
    kinds = kind.split()
    rmodels = AccumDict()
    for kind in kinds:
        for key in sorted(oqparam.inputs):
            mo = re.match('(occupants|%s)_%s$' % (COST_TYPE_REGEX, kind), key)
            if mo:
                loss_type = mo.group(1)  # the cost_type in the key
                # can be occupants, structural, nonstructural, ...
                rmodel = nrml.to_python(oqparam.inputs[key])
                if len(rmodel) == 0:
                    raise InvalidFile('%s is empty!' % oqparam.inputs[key])
                rmodels[loss_type, kind] = rmodel
                if rmodel.lossCategory is None:  # NRML 0.4
                    continue
                cost_type = str(rmodel.lossCategory)
                rmodel_kind = rmodel.__class__.__name__
                kind_ = kind.replace('_retrofitted', '')  # strip retrofitted
                if not rmodel_kind.lower().startswith(kind_):
                    raise ValueError(
                        'Error in the file "%s_file=%s": is '
                        'of kind %s, expected %s' % (
                            key, oqparam.inputs[key], rmodel_kind,
                            kind.capitalize() + 'Model'))
                if cost_type != loss_type:
                    raise ValueError(
                        'Error in the file "%s_file=%s": lossCategory is of '
                        'type "%s", expected "%s"' %
                        (key, oqparam.inputs[key],
                         rmodel.lossCategory, loss_type))
    rdict = AccumDict(accum={})
    rdict.limit_states = []
    for (loss_type, kind), rm in sorted(rmodels.items()):
        if kind == 'fragility':
            # build a copy of the FragilityModel with different IM levels
            newfm = rm.build(oqparam.continuous_fragility_discretization,
                             oqparam.steps_per_interval)
            for (imt, riskid), ffl in newfm.items():
                if not rdict.limit_states:
                    rdict.limit_states.extend(rm.limitStates)
                # we are rejecting the case of loss types with different
                # limit states; this may change in the future
                assert rdict.limit_states == rm.limitStates, (
                    rdict.limit_states, rm.limitStates)
                rdict[riskid][loss_type, kind] = ffl
                # TODO: see if it is possible to remove the attribute
                # below, used in classical_damage
                ffl.steps_per_interval = oqparam.steps_per_interval
        elif kind == 'consequence':
            for riskid, cf in rm.items():
                rdict[riskid][loss_type, kind] = cf
        else:  # vulnerability
            cl_risk = oqparam.calculation_mode in (
                'classical', 'classical_risk')
            # only for classical_risk reduce the loss_ratios
            # to make sure they are strictly increasing
            for (imt, riskid), rf in rm.items():
                rdict[riskid][loss_type, kind] = (
                    rf.strictly_increasing() if cl_risk else rf)
    return rdict
532101
function createNativeDOMException(name, message) {
        var e = new DOMException.prototype.constructor(0, message);
        e.name = name || 'DOMException';
        e.message = message;
        return e;
    }
1373515
function extractError (e) {
  return {
    message: e.message,
    file: getFile(e),
    origin: getOrigin(e),
    name: e.name,
    severity: 0,
    webpackError: e,
    originalStack: getOriginalErrorStack(e)
  };
}
1057584
function modelIndexErrors(errors, context) {
        if (context && context.modelIndexErrors) {
            return context.modelIndexErrors(errors);
        }
        if (Array.isArray(errors)) {
            var rtn = {};
            _.each(errors, function(data) {
                for (var name in data) {
                    if (data.hasOwnProperty(name)) {
                        rtn[name] = data[name];
                    }
                }
            });
            return rtn;
        } else {
            return errors;
        }
    }
42622
void reportInstError(UndetVar uv, InferenceBound ib) {
        reportInferenceError(
                String.format("inferred.do.not.conform.to.%s.bounds", StringUtils.toLowerCase(ib.name())),
                uv.getInst(),
                uv.getBounds(ib));
    }
72176
def M(self, k, t, tips=None, gaps=None):
        """"""
        assert 0 <= k < self.ncats
        return self._models[k].M(t, tips=tips, gaps=gaps)
1243333
def create_mnist_model(hyper_params, input_shape=(H, W, 1), num_classes=NUM_CLASSES):
    '''
    
    '''
    layers = [
        Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=input_shape),
        Conv2D(64, (3, 3), activation='relu'),
        MaxPooling2D(pool_size=(2, 2)),
        Flatten(),
        Dense(100, activation='relu'),
        Dense(num_classes, activation='softmax')
    ]

    model = Sequential(layers)

    if hyper_params['optimizer'] == 'Adam':
        optimizer = keras.optimizers.Adam(lr=hyper_params['learning_rate'])
    else:
        optimizer = keras.optimizers.SGD(lr=hyper_params['learning_rate'], momentum=0.9)
    model.compile(loss=keras.losses.categorical_crossentropy, optimizer=optimizer, metrics=['accuracy'])

    return model
668089
function onError (data) {
    var map = sourceMap.map()
    var error
    var smc

    if (!data.length) {
      return
    }

    // if what we get isn't json, it's some other undescribed phantom error;
    // just echo it.
    try {
      error = JSON.parse(data.toString())
    } catch (e) {
      io.stderr.write(sprintf('\n\n%s\n', data.toString()))

      return
    }

    // if a source map wasn't present, just output the line numbers where an
    // error occurred
    if (!map) {
      io.stderr.write(sprintf('\n\n%s\n', error.message))

      if (error.trace && error.trace.length) {
        error.trace.forEach(function (e) {
          io.stderr.write(sprintf('    at :%d', e.line))

          if (e.function) {
            io.stderr.write(sprintf(' (in function %s)', e.function))
          }

          io.stderr.write('\n')
        })
      }

      return
    }

    // else, make sense of the sourcemap and output that information
    smc = new Consumer(map)

    io.stderr.write(sprintf('\n\n%s\n', error.message))

    if (error.trace && error.trace.length) {
      error.trace.forEach(function (e) {
        if (!e.line) {
          return
        }

        // phantom doesn't provide columns in stack traces
        var err = smc.originalPositionFor(
            {line: e.line, column: e.column || 0}
        )

        io.stderr.write(sprintf('    at %s:%d\n', err.source, err.line))
      })
    }
  }
258018
function errHandler(err) {
    process.stderr.write(chalk.red('Model generation failed!') + '\n');

    switch (err.code) {
      default:
        case 'PARSE_FAIL':
        if (!quiet) {
          process.stderr.write('\n' + err.stack + '\n');
        }
      break;

      case 'ENOENT':
          if (!quiet) {
            process.stderr.write('\n' + err.stack.replace('ENOENT, lstat ', 'unable to find ') + '\n');
          }
        break;
    }
    callback(err);
  }
430819
def _xval_model_error(self, fit_spectra, reject_outliers, fit_lb, fit_ub,
                           fitter, func):
        
        set1 = fit_spectra[::2]
        set2 = fit_spectra[1::2]
        errs = []
        signal_select = [] 
        models = []
        signals = []
        for this_set in [set1, set2]:
            choose_transients, model, signal, params, this_idx =\
                self._fit_helper(this_set, reject_outliers,
                                 fit_lb, fit_ub, fitter)
            models.append(np.nanmean(model[choose_transients], 0))
            signals.append(np.nanmean(signal[choose_transients], 0))

            signal_select.append(signal[choose_transients])
                
        #Cross-validation error estimation:
        model_err = np.mean([ut.rmse(models[0], signals[1]),
                              ut.rmse(models[1], signals[0])])
        # Also for the signal:
        signal_err = ut.rmse(np.nanmean(signal_select[0], 0),
                             np.nanmean(signal_select[1], 0))
        # Based on the errors, choose a function. Also report errors:
        return model_err, signal_err
706395
def p_Exception(p):
  
  p[0] = model.Exception(name=p[2], parent=p[3], members=p[5])
494097
function onOutError(err) {
    errNodecat = combineErrors(errNodecat, err);
    errStream.write(`nodecat: ${err}\n`);
    if (inCleanup) {
      inCleanup();
    }
    allDone();
  }
345471
def class_error(self, input_data, targets, average=True,
                    cache=None, prediction=False):
        

        if cache is not None:
            activations = cache
        else:
            activations = \
              self.feed_forward(input_data, prediction=prediction)

        targets = targets.get().argmax(1)
        class_error = np.sum(activations.get().argmax(1) != targets)

        if average: class_error = float(class_error) / targets.shape[0]
        return class_error
1288312
def kl_error(self, input_data, targets, average=True,
                 cache=None, prediction=True):
        

        if cache is not None:
            activations = cache
        else:
            activations = \
              self.feed_forward(input_data, prediction=prediction)

        targets_non_nan = gpuarray.empty_like(targets)
        nan_to_zeros(targets, targets_non_nan)
        kl_error = gpuarray.sum(targets_non_nan *
                                (cumath.log(targets_non_nan + eps) -
                                 cumath.log(activations + eps)))
        if average:
            kl_error /= targets.shape[0]
        return kl_error.get()
1109436
def std_err(self):
        

        return np.sqrt(np.sum(np.square(self.resids), axis=0) / self.df_err)
961157
private static ModelAndView paramError(Map<String, String> paramErrors, Map<String, Object[]> paramArgusErrors,
                                           ErrorCode errorCode) {

        JsonObjectBase jsonObject = JsonObjectUtils.buildFieldError(paramErrors, paramArgusErrors, errorCode);
        return JsonObjectUtils.JsonObjectError2ModelView((JsonObjectError) jsonObject);
    }