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


Python model.MLP属性代码示例

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


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

示例1: make_basic_cnn

# 需要导入模块: import model [as 别名]
# 或者: from model import MLP [as 别名]
def make_basic_cnn(nb_filters=64, nb_classes=10,
                   input_shape=(None, 28, 28, 1)):
    layers = [Conv2D(nb_filters, (8, 8), (2, 2), "SAME"),
              ReLU(),
              Conv2D(nb_filters * 2, (6, 6), (2, 2), "VALID"),
              ReLU(),
              Conv2D(nb_filters * 2, (5, 5), (1, 1), "VALID"),
              ReLU(),
              Flatten(),
              Linear(nb_classes),
              Softmax()]

    model = MLP(nb_classes, layers, input_shape)
    return model 
开发者ID:StephanZheng,项目名称:neural-fingerprinting,代码行数:16,代码来源:make_model.py

示例2: load_npz_file_to_model

# 需要导入模块: import model [as 别名]
# 或者: from model import MLP [as 别名]
def load_npz_file_to_model(npz_filename='model.npz'):
    # Create model object first
    model1 = model.MLP()

    # Load the saved parameters into the model object
    chainer.serializers.load_npz(npz_filename, model1)
    print('{} loaded!'.format(npz_filename))

    return model1 
开发者ID:chainer,项目名称:chainer,代码行数:11,代码来源:load.py

示例3: load_hdf5_file_to_model

# 需要导入模块: import model [as 别名]
# 或者: from model import MLP [as 别名]
def load_hdf5_file_to_model(hdf5_filename='model.h5'):
    # Create another model object first
    model2 = model.MLP()

    # Load the saved parameters into the model object
    chainer.serializers.load_hdf5(hdf5_filename, model2)
    print('{} loaded!'.format(hdf5_filename))

    return model2 
开发者ID:chainer,项目名称:chainer,代码行数:11,代码来源:load.py

示例4: make_basic_cnn

# 需要导入模块: import model [as 别名]
# 或者: from model import MLP [as 别名]
def make_basic_cnn(nb_filters=64, nb_classes=10,
                   input_shape=(None, 28, 28, 1)):
  layers = [Conv2D(nb_filters, (8, 8), (2, 2), "SAME"),
            ReLU(),
            Conv2D(nb_filters * 2, (6, 6), (2, 2), "VALID"),
            ReLU(),
            Conv2D(nb_filters * 2, (5, 5), (1, 1), "VALID"),
            ReLU(),
            Flatten(),
            Linear(nb_classes),
            Softmax()]

  model = MLP(nb_classes, layers, input_shape)
  return model 
开发者ID:tensorflow,项目名称:cleverhans,代码行数:16,代码来源:make_model.py

示例5: gemm_config

# 需要导入模块: import model [as 别名]
# 或者: from model import MLP [as 别名]
def gemm_config(M, N, K, logits_dict):
    spatial_split_parts = 4
    reduce_split_parts = 4
    unroll_max_factor = 10

    sy = any_factor_split(M, spatial_split_parts)
    sx = any_factor_split(N, spatial_split_parts)
    sk = any_factor_split(K, reduce_split_parts)
    unroll = []
    for i in range(1):
        for j in range(unroll_max_factor + 1):
            unroll.append([i, 2**j])

    def _rational(lst, max_val):
        return torch.FloatTensor([[y / float(max_val) for y in x] for x in lst])
    nsy = _rational(sy, M)
    nsx = _rational(sx, N)
    nsk = _rational(sk, K)
    
    n_unroll = torch.FloatTensor([[x[0] / float(2) + 0.5, math.log2(x[1]) / 1] for x in unroll])

    # get logits
    spatial_logits = logits_dict["spatial"]
    reduce_logits = logits_dict["reduce"]
    unroll_logits = logits_dict["unroll"]
    
    # make choice
    feature_size = len(logits_dict["spatial"][0])
    split_classifier = model.MLP(feature_size + spatial_split_parts)
    unroll_classifier = model.MLP(feature_size + 2)
    cy = torch.argmax(split_classifier(torch.cat([nsy, torch.zeros([nsy.shape[0], feature_size]) + spatial_logits[0]], dim=1)))
    cx = torch.argmax(split_classifier(torch.cat([nsx, torch.zeros([nsx.shape[0], feature_size]) + spatial_logits[1]], dim=1)))
    ck = torch.argmax(split_classifier(torch.cat([nsk, torch.zeros([nsk.shape[0], feature_size]) + reduce_logits[0]], dim=1)))
    cu = torch.argmax(unroll_classifier(torch.cat([n_unroll, torch.zeros([n_unroll.shape[0], feature_size]) + unroll_logits], dim=1)))

    print(cy, cx, ck, cu)
    
    # print choice
    print("Print choice")
    print("split y =", sy[cy])
    print("split x =", sx[cx])
    print("split k =", sk[ck])
    print("unroll", unroll[cu])

    # make config
    op_config = [{
        "spatial": [sy[cy], sx[cx]],
        "reduce": [sk[ck]],
        "inline": [],
        "unroll": [unroll[cu]]
    }]
    graph_config = {
        "spatial": [], 
        "reduce": [], 
        "inline": [[0]], 
        "unroll": []
    }
    return Config(op_config, graph_config) 
开发者ID:KnowingNothing,项目名称:FlexTensor,代码行数:60,代码来源:example.py


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