2013-07-25 3 views
1

python 명령의 데이터를 yaml 파일에 추가 할 수 있습니까? 다음은 YAML 파일입니다 :Python과 Yaml 파일에 오브젝트 삽입

!obj:pylearn2.train.Train {  
    dataset: !obj:pylearn2.datasets.hepatitis.Hepatitis &dataset { 
    }, 
    model: !obj:pylearn2.models.mlp.MLP { 
     batch_size: 50, 
     layers : [ 
      # We use two hidden layers with maxout activations 

      !obj:pylearn2.models.maxout.Maxout { 
       layer_name: 'h0', 
       num_units: 300, 
       num_pieces: 2, 
       irange: 0.5, 
      }, 

      #I want to add another of !obj:pylearn2.models.maxout.Maxout{...} from my python file... 

      !obj:pylearn2.models.mlp.Softmax { 
       layer_name: 'y', 
       # Initialize the weights to all 0s 
       irange: 0.5, 
       n_classes: 2 
      } 
     ], 
     nvis: 2612, 
    }, 
    algorithm: !obj:pylearn2.training_algorithms.sgd.SGD { 
     learning_rate : 1e-3, 
     batch_size : 50, 
     monitoring_batches : 20, 
     monitoring_dataset : *dataset, 
     termination_criterion : !obj:pylearn2.termination_criterion.MonitorBased { 
      prop_decrase: .01, 
      N : 35 
     }, 
    } , 
    #save the pickle file to the current directory 
    save_path : ./garbageprova.pkl, 
    #frequency of updating the file 
    save_freq : 100 
} 

가 어떻게 내 model.layers[] 목록에 다른 요소를 추가 할 수 있습니다 ?

답변

0

PyYAML을 사용하면 Python에서 YAML을 처리 할 수 ​​있습니다. 홈 페이지의 PyYAML documentation 및 예를 살펴보십시오. 이들은 귀하의 요구 사항을 해결하는 방법에 대한 아이디어를 제공해야합니다.

관련 문제