コード例 #1
0
    def __getattr__(self, item):
        from functools import partial as _p
        """Make an alignment for easy calls. You can add more patterns as below.
        
        >>> Layers.relu_conv2d = Layers.conv2d(activation='relu')
        >>> Layers.bn_conv2d = Layers.conv2d(use_batchnorm=True)
        >>> Layers.sn_leaky_conv2d = Layers.conv2d(use_sn=True, activation='lrelu')
        
        NOTE: orders do not matter.
        """
        if 'deconv2d' in item:
            pass
        elif 'conv2d' in item:
            items = item.split('_')
            kwargs = {
                'kernel_initializer': 'he_normal',
                'kernel_regularizer': 'l2',
                'use_batchnorm': False,
                'use_sn': False,
            }
            if 'bn' in items or 'batchnorm' in items:
                kwargs.update(use_batchnorm=True)
            if 'sn' in items or 'spectralnorm' in items:
                kwargs.update(use_sn=True)
            if 'relu' in items:
                kwargs.update(activation='relu')
            if 'leaky' in items or 'lrelu' in items or 'leakyrelu' in items:
                kwargs.update(activation='lrelu')
            if 'prelu' in items:
                kwargs.update(activation='prelu')
            if 'tanh' in items:
                kwargs.update(activation='tanh')
            return _p(self.conv2d, **kwargs)
        elif 'conv3d' in item:
            items = item.split('_')
            kwargs = {
                'kernel_initializer': 'he_normal',
                'kernel_regularizer': 'l2',
                'use_batchnorm': False,
            }
            if 'bn' in items or 'batchnorm' in items:
                kwargs.update(use_batchnorm=True)
            if 'relu' in items:
                kwargs.update(activation='relu')
            if 'leaky' in items or 'lrelu' in items or 'leakyrelu' in items:
                kwargs.update(activation='lrelu')
            if 'prelu' in items:
                kwargs.update(activation='prelu')
            if 'tanh' in items:
                kwargs.update(activation='tanh')
            return _p(self.conv3d, **kwargs)
        elif 'dense' in item or 'linear' in item:
            items = item.split('_')
            kwargs = {
                'kernel_initializer': 'he_normal',
                'kernel_regularizer': 'l2',
                'use_sn': False,
            }
            if 'sn' in items or 'spectralnorm' in items:
                kwargs.update(use_sn=True)
            if 'relu' in items:
                kwargs.update(activation='relu')
            if 'leaky' in items or 'lrelu' in items or 'leakyrelu' in items:
                kwargs.update(activation='lrelu')
            if 'prelu' in items:
                kwargs.update(activation='prelu')
            if 'tanh' in items:
                kwargs.update(activation='tanh')
            return _p(self.dense, **kwargs)

        return None
コード例 #2
0
ファイル: checks.py プロジェクト: BradenM/micropy-cli
    """
    try:
        name, vers = next(iter_vscode_ext(name=ext), (ext, "0.0.0"))
    except Exception as e:
        log.debug(f"vscode check failed to run: {e}")
        log.debug("skipping...")
        return True
    else:
        cur_vers = version.parse(vers)
        min_vers = version.parse(min_version)
        if cur_vers >= min_vers:
            return True
        log.error(f"\nVSCode Extension {ext} failed to satisfy requirements!",
                  bold=True)
        log.error(f"$[Min Required Version]: {min_vers}")
        log.error(f"$[Current Version:] {cur_vers}")
        if info:
            log.warn(info)
        return False


TEMPLATE_CHECKS = {
    "ms-python":
    _p(
        vscode_ext_min_version,
        "ms-python.python",
        info=("VSCode Integration will fail! "
              "See $[BradenM/micropy-cli#50] for details.\n"),
    ),
}
コード例 #3
0
ファイル: sandbox.py プロジェクト: qixiaofeng-gst/uinp
 def __get__(self, instance, owner):
     print(f'Let\'s rock: {type(instance)} {type(owner)}')
     return _p(self.__call__, instance)
コード例 #4
0
                        encoding='utf-8',
                        xml_declaration=True,
                        pretty_print=True)


addWorkflowFactory(InteractionWorkflowDefinition,
                   id='interaction_workflow',
                   title='Web-configurable interaction workflow')

## Avoid copy/paste from Products.ERP5Type.Core.InteractionWorkflowInteraction
from functools import partial as _p
from Products.ERP5Type.Core.InteractionWorkflow import InteractionWorkflow as ERP5InteractionWorkflow
InteractionWorkflowDefinition.security = ClassSecurityInfo()
_s = InteractionWorkflowDefinition.security
for method_name, security in (
    ('getChainedPortalTypeList', _p(_s.declareProtected, Permissions.View)),
    ('listObjectActions', _s.declarePrivate),
    ('_changeStateOf', _s.declarePrivate),
    ('notifyWorkflowMethod', _s.declarePrivate),
    ('wrapWorkflowMethod', _s.declarePrivate),
    ('_getWorkflowStateOf', None),
    ('isInfoSupported', _s.declarePrivate),
    ('getInfoFor', _s.declarePrivate),
    ('isWorkflowMethodSupported', _s.declarePrivate),
    ('notifyBefore', _s.declarePrivate),
    ('notifySuccess', _s.declarePrivate),
):
    if security is not None:
        security(method_name)
    setattr(
        InteractionWorkflowDefinition, method_name,