当前位置: 首页>>代码示例>>Python>>正文


Python numpy.__name__方法代码示例

本文整理汇总了Python中numpy.__name__方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.__name__方法的具体用法?Python numpy.__name__怎么用?Python numpy.__name__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.__name__方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _model_to_dict

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def _model_to_dict(model):
        """Convert a sklearn model object to a dictionary"""
        dictionary = {
            "module": type(model).__module__,
            "class": type(model).__name__,
            "params": model.get_params(deep=True),
            "coefs": {
                attr: copy.deepcopy(getattr(model, attr))
                for attr in model.__dir__()
                if not attr.startswith("__") and attr.endswith("_")
            }
        }

        if "tree_" in dictionary["coefs"]:
            # Not funny. sklearn.tree objects are not directly
            # serializable to json. Hence, we must dump them by ourselves.
            dictionary["coefs"]["tree_"] = RetrievalProduct._tree_to_dict(
                dictionary["coefs"]["tree_"]
            )

        return RetrievalProduct._encode_numpy(dictionary) 
开发者ID:atmtools,项目名称:typhon,代码行数:23,代码来源:common.py

示例2: count_params

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def count_params(self):
    """Count the total number of scalars composing the weights.

    Returns:
        An integer count.

    Raises:
        RuntimeError: if the layer isn't yet built
            (in which case its weights aren't yet defined).
    """
    if not self.built:
      if self.__class__.__name__ == 'Sequential':
        self.build()  # pylint: disable=no-value-for-parameter
      else:
        raise RuntimeError('You tried to call `count_params` on ' + self.name +
                           ', but the layer isn\'t built. '
                           'You can build it manually via: `' + self.name +
                           '.build(batch_input_shape)`.')
    return sum([K.count_params(p) for p in self.weights]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:topology.py

示例3: _updated_config

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def _updated_config(self):
    """Util hared between different serialization methods.

    Returns:
        Model config with Keras version information added.
    """
    from tensorflow.contrib.keras.python.keras import __version__ as keras_version  # pylint: disable=g-import-not-at-top

    config = self.get_config()
    model_config = {
        'class_name': self.__class__.__name__,
        'config': config,
        'keras_version': keras_version,
        'backend': K.backend()
    }
    return model_config 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:18,代码来源:topology.py

示例4: _updated_config

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def _updated_config(self):
        """Util hared between different serialization methods.

        # Returns
            Model config with Keras version information added.
        """
        from .. import __version__ as keras_version

        config = self.get_config()
        model_config = {
            'class_name': self.__class__.__name__,
            'config': config,
            'keras_version': keras_version,
            'backend': K.backend()
        }
        return model_config 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:18,代码来源:network.py

示例5: to_json

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def to_json(self, **kwargs):
        """Returns a JSON string containing the timeseries generator
        configuration. To load a generator from a JSON string, use
        `keras.preprocessing.sequence.timeseries_generator_from_json(json_string)`.

        # Arguments
            **kwargs: Additional keyword arguments
                to be passed to `json.dumps()`.

        # Returns
            A JSON string containing the tokenizer configuration.
        """
        config = self.get_config()
        timeseries_generator_config = {
            'class_name': self.__class__.__name__,
            'config': config
        }
        return json.dumps(timeseries_generator_config, **kwargs) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:sequence.py

示例6: test_linear_regression_numpy

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def test_linear_regression_numpy(self):
        """ Test the linear regression using numpy (if installed). """
        # test that numpy is installed
        try:
            import numpy
            numpy.__name__
        except ImportError:
            raise unittest.SkipTest('cannot test as optional numpy is not installed')
        # perform the test with numpy
        from supvisors.utils import get_linear_regression, get_simple_linear_regression
        xdata = [2, 4, 6, 8, 10, 12]
        ydata = [3, 4, 5, 6, 7, 8]
        # test linear regression
        a, b = get_linear_regression(xdata, ydata)
        self.assertAlmostEqual(0.5, a)
        self.assertAlmostEqual(2.0, b)
        # test simple linear regression
        a, b = get_simple_linear_regression(ydata)
        self.assertAlmostEqual(1.0, a)
        self.assertAlmostEqual(3.0, b) 
开发者ID:julien6387,项目名称:supvisors,代码行数:22,代码来源:test_utils.py

示例7: init_backends

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def init_backends():
    init_environment()

    # populate available backend modules
    global BACKENDS
    BACKENDS = {}

    import numpy
    if numpy.__name__ == 'bohrium':
        logger.warning('Running veros with "python -m bohrium" is discouraged '
                       '(use "--backend bohrium" instead)')
        import numpy_force
        numpy = numpy_force

    BACKENDS['numpy'] = numpy

    try:
        import bohrium
    except ImportError:
        logger.warning('Could not import Bohrium (Bohrium backend will be unavailable)')
        BACKENDS['bohrium'] = None
    else:
        BACKENDS['bohrium'] = bohrium 
开发者ID:team-ocean,项目名称:veros,代码行数:25,代码来源:backend.py

示例8: _clean

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def _clean(value):
    """ Convert numpy numeric types to their python equivalents. """
    if isinstance(value, np.ndarray):
        if value.dtype.kind == 'S':
            return np.char.decode(value).tolist()
        else:
            return value.tolist()
    elif type(value).__module__ == np.__name__:
        # h5py==2.8.0 on windows sometimes fails to cast this from an np.float64 to a python.float
        # We have to let the user do this themselves, since casting here could be dangerous
        # https://github.com/h5py/h5py/issues/1051
        conversion = value.item()  # np.asscalar(value) was deprecated in v1.16
        if isinstance(conversion, bytes):
            conversion = conversion.decode()
        return conversion
    elif isinstance(value, bytes):
        return value.decode()
    else:
        return value 
开发者ID:nanoporetech,项目名称:ont_fast5_api,代码行数:21,代码来源:data_sanitisation.py

示例9: type_to_builtin_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def type_to_builtin_type(type):
    # Infer from numpy type if it is one
    if type.__module__ == np.__name__:
        return numpy_type_to_builtin_type(type)

    # Otherwise, try to infer from a few generic python types
    if np.issubclass_(type, bool):
        return types_bool
    elif np.issubclass_(type, six.integer_types):
        return types_int32
    elif np.issubclass_(type, six.string_types):
        return types_str
    elif np.issubclass_(type, float):
        return types_fp32
    else:
        raise TypeError("Could not determine builtin type for " + str(type)) 
开发者ID:apple,项目名称:coremltools,代码行数:18,代码来源:type_mapping.py

示例10: all_same

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def all_same(val_array):
    '''
    Check if all the values in given list the same

    Parameters
    ----------
    numpy_list: numpy array
    '''

    # check if val_array is a numpy array
    if type(val_array).__module__ == np.__name__:
        val = val_array.tolist()
        if isinstance(val[0], list):
            #handle list of lists
            return all(round(x[0]) == round(val[0][0]) for x in val)
        else:
            #handle single list
            return all(round(x) == round(val[0]) for x in val)
    else:
        raise Exception('This function only takes a numpy array') 
开发者ID:Quantipy,项目名称:quantipy,代码行数:22,代码来源:pptx_painter.py

示例11: face_covered_frame

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def face_covered_frame(self, input_frame_with_faces):
        """Function to draw black recs over detected faces.

        This function remove eny 'noise' and help detector detecting palm.
        :param input_frame_with_faces (np.ndarray): a frame with faces, that needed to be covered.
        """

        try:
            # make sure input is np.ndarray
            assert type(input_frame_with_faces).__module__ == np.__name__
        except AssertionError as error:
            self.logger.exception(error)
            return

        # Preparation
        self._preprocessed_input_frame = input_frame_with_faces.copy()
        gray = cv2.cvtColor(self._preprocessed_input_frame, cv2.COLOR_BGR2GRAY)
        faces = self._face_detector.detectMultiScale(gray, 1.3, 5)

        # Black rectangle over faces to remove skin noises.
        for (x, y, w, h) in faces:
            self._preprocessed_input_frame[y - self._face_padding_y:y + h + self._face_padding_y,
            x - self._face_padding_x:x + w + self._face_padding_x, :] = 0 
开发者ID:GalBrandwine,项目名称:HalloPy,代码行数:25,代码来源:controller.py

示例12: compute_output_shape

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def compute_output_shape(self, input_shape):
        """Computes the output shape of the layer.

        Assumes that the layer will be built
        to match that input shape provided.

        # Arguments
            input_shape: Shape tuple (tuple of integers)
                or list of shape tuples (one per output tensor of the layer).
                Shape tuples can include None for free dimensions,
                instead of an integer.

        # Returns
            An input shape tuple.
        """
        if hasattr(self, 'get_output_shape_for'):
            msg = "Class `{}.{}` defines `get_output_shape_for` but does not override `compute_output_shape`. " + \
                  "If this is a Keras 1 layer, please implement `compute_output_shape` to support Keras 2."
            warnings.warn(msg.format(type(self).__module__, type(self).__name__), stacklevel=2)
        return input_shape 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:22,代码来源:topology.py

示例13: count_params

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import __name__ [as 别名]
def count_params(self):
        """Counts the total number of scalars composing the weights.

        # Returns
            An integer count.

        # Raises
            RuntimeError: if the layer isn't yet built
                (in which case its weights aren't yet defined).
        """
        if not self.built:
            if self.__class__.__name__ == 'Sequential':
                self.build()
            else:
                raise RuntimeError('You tried to call `count_params` on ' +
                                   self.name + ', but the layer isn\'t built. '
                                   'You can build it manually via: `' +
                                   self.name + '.build(batch_input_shape)`.')
        return count_params(self.weights) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:21,代码来源:topology.py


注:本文中的numpy.__name__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。