2017-01-19 33 views
2

我得到的數據文件,象下面這樣:CNTK Python中如何將多個功能傳遞到模型

|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 1.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 1.00 99.00 |Player5 5 0.00 100.00 |Action 0 0 1 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 2.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 2.00 98.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 3.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 3.00 97.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 4.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 4.00 96.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 5.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 5.00 95.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 6.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 6.00 94.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 7.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 7.00 93.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 8.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 8.00 92.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 9.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 9.00 91.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 100.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 100.00 0.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 10.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 10.00 90.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 15.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 15.00 85.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 20.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 20.00 80.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 30.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 30.00 70.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 40.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 40.00 60.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 50.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 50.00 50.00 |Player5 5 0.00 100.00 |Action 0 0 1 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 60.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 60.00 40.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 70.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 70.00 30.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 80.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 80.00 20.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 90.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 90.00 10.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 3 |HeroPosition 3 |Pot 0.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 0.00 100.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 0 1 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 1.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 1.00 99.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 2.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 2.00 98.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 3.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 3.00 97.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 4.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 4.00 96.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 7.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 7.00 93.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 1 0 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 2 |HeroPosition 5 |Pot 8.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 8.00 92.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 1 0 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 3 |HeroPosition 4 |Pot 1.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 1.00 99.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 3 |HeroPosition 4 |Pot 2.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 2.00 98.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 3 |HeroPosition 4 |Pot 100.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 100.00 0.00 |Player4 4 0.00 100.00 |Player5 5 0.00 100.00 |Action 0 1 0 
|HandPercentage 0.5958 |NoOfPlayersInPlay 3 |HeroPosition 5 |Pot 2.00 |Player0 0 0.00 100.00 |Player1 1 0.00 100.00 |Player2 2 0.00 100.00 |Player3 3 1.00 99.00 |Player4 4 1.00 99.00 |Player5 5 0.00 100.00 |Action 0 1 0 

我使用CNTK與蟒蛇,我的讀者是象下面這樣:

def create_reader(path): 
    streams = CTFDeserializer(path, StreamDefs(
     HandPercentage = StreamDef(field='HandPercentage', shape=input_dim, is_sparse=False), 
     NoOfPlayersInPlay = StreamDef(field='NoOfPlayersInPlay', shape=input_dim, is_sparse=False), 
     HeroPosition = StreamDef(field='HeroPosition', shape=input_dim, is_sparse=False), 
     Pot = StreamDef(field='Pot', shape=input_dim, is_sparse=False), 
     Player0 = StreamDef(field='Player0', shape=player_dim, is_sparse=False), 
     Player1 = StreamDef(field='Player1', shape=player_dim, is_sparse=False), 
     Player2 = StreamDef(field='Player2', shape=player_dim, is_sparse=False), 
     Player3 = StreamDef(field='Player3', shape=player_dim, is_sparse=False), 
     Player4 = StreamDef(field='Player4', shape=player_dim, is_sparse=False), 
     Player5 = StreamDef(field='Player5', shape=player_dim, is_sparse=False), 
     labels = StreamDef(field='Action', shape=label_dim, is_sparse=False))) 
    return MinibatchSource(streams) 

當我需要訓練我的模型,我需要把所有的節點一起,我創建了一個input_map象下面這樣:

input_dim = 1 
player_dim = 3 
label_dim = 3 

.... 

HandPercentage = Input(input_dim, is_sparse=False) 
NoOfPlayersInPlay = Input(input_dim, is_sparse=False) 
HeroPosition = Input(input_dim, is_sparse=False) 
Pot = Input(input_dim, is_sparse=False) 
Player0 = Input(player_dim, is_sparse=False) 
Player1 = Input(player_dim, is_sparse=False) 
Player2 = Input(player_dim, is_sparse=False) 
Player3 = Input(player_dim, is_sparse=False) 
Player4 = Input(player_dim, is_sparse=False) 
Player5 = Input(player_dim, is_sparse=False) 
labels = Input(label_dim, is_sparse=False) # TODO: make sparse once it works 

input_map = { 
    HandPercentage : reader.streams.HandPercentage, 
    NoOfPlayersInPlay : reader.streams.NoOfPlayersInPlay, 
    HeroPosition : reader.streams.HeroPosition, 
    Pot : reader.streams.Pot, 
    Player0 : reader.streams.Player0, 
    Player1 : reader.streams.Player1, 
    Player2 : reader.streams.Player2, 
    Player3 : reader.streams.Player3, 
    Player4 : reader.streams.Player4, 
    Player5 : reader.streams.Player5, 
    labels : reader.streams.labels 
} 

我想toget加入他們的行列她然後將它們傳遞到我的火車模型:

inputs = [] 
inputs.append(HandPercentage) 
inputs.append(NoOfPlayersInPlay) 
inputs.append(HeroPosition) 
inputs.append(Pot) 
inputs.append(Player0) 
inputs.append(Player1) 
inputs.append(Player2) 
inputs.append(Player3) 
inputs.append(Player4) 
inputs.append(Player5) 

features = inputs 

# apply model to input 
z = model(features) 

有誰知道我怎麼會做同樣喜歡RowStack在BrainScript的東西嗎?

回答

2

由於您具有所有密集功能,因此如果可能的話,在生成輸入文件時爲什麼不將所有輸入連接在一個平面特徵矢量中以便開始。

相關問題