我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用builtins.min()。
def __call__(self, *inputvals): assert len(inputvals) == len(self.nondata_inputs) + len(self.data_inputs) nondata_vals = inputvals[0:len(self.nondata_inputs)] data_vals = inputvals[len(self.nondata_inputs):] feed_dict = dict(zip(self.nondata_inputs, nondata_vals)) n = data_vals[0].shape[0] for v in data_vals[1:]: assert v.shape[0] == n for i_start in range(0, n, self.batch_size): slice_vals = [v[i_start:builtins.min(i_start + self.batch_size, n)] for v in data_vals] for (var, val) in zip(self.data_inputs, slice_vals): feed_dict[var] = val results = tf.get_default_session().run(self.outputs, feed_dict=feed_dict) if i_start == 0: sum_results = results else: for i in range(len(results)): sum_results[i] = sum_results[i] + results[i] for i in range(len(results)): sum_results[i] = sum_results[i] / n return sum_results # ================================================================ # Modules # ================================================================
def min(x, axis=None, keepdims=False): axis = None if axis is None else [axis] return tf.reduce_min(x, axis=axis, keep_dims=keepdims)
def _process_arguments(self, args, keywords): argdict = {} nargs = min(len(args), len(self._argnames)) for iarg in range(nargs): argdict[self._argnames[iarg]] = args[iarg] if nargs < len(args): if self._varargs is None: msg = "macro '{0}' called with too many positional arguments "\ "(expected: {1}, received: {2})"\ .format(self._name, len(self._argnames), len(args)) raise FyppFatalError(msg, self._fname, self._spans[0]) else: argdict[self._varargs] = tuple(args[nargs:]) elif self._varargs is not None: argdict[self._varargs] = () for argname in self._argnames[:nargs]: if argname in keywords: msg = "got multiple values for argument '{0}'".format(argname) raise FyppFatalError(msg, self._fname, self._spans[0]) if self._varargs is not None and self._varargs in keywords: msg = "got unexpected keyword argument '{0}'".format(self._varargs) raise FyppFatalError(msg, self._fname, self._spans[0]) argdict.update(keywords) if nargs < len(self._argnames): for argname in self._argnames[nargs:]: if argname in argdict: pass elif argname in self._defaults: argdict[argname] = self._defaults[argname] else: msg = "macro '{0}' called without mandatory positional "\ "argument '{1}'".format(self._name, argname) raise FyppFatalError(msg, self._fname, self._spans[0]) return argdict
def min(*args): """Replacement for the built-in :func:`min() <python:min>` function.""" return builtins.min(*args)