當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。