Figure 1에 그려진 다음과 같은 4가지 Components 를 설정하여 트레이닝을 시작합니다.
Basic 유저 가이드 에서 built-in components 를 써서 트레이닝을 시작하는 방법을 설명합니다. Advanced 유저 가이드 에서는 유저가 임플리멘트한 모델, 함수, 알고리듬을 써서 트레이닝을 시작하는 방법을 설병합니다. 트레이닝 데이타는 process 를 참고로 준비를 해주세요.
Figure 1 - SINGA Overview
SINGA 에서 준비된 main 함수를 써서 쉽게 트레이닝을 시작할수 있습니다. 이 경우 JobProto 를 위하여 google protocol buffer message 로 씌여진 job configuration 파일을 준비합니다. 그리고 아래의 커맨드라인을 실행합니다.
./bin/singa-run.sh -conf <path to job conf> [-resume]
-resume 는 트레이닝을 저번 checkpoint 부터 다시 계속할때 쓰는 인수 입니다. MLP 와 CNN 샘플들은 built-in 컴포넌트를 쓰고 있습니다. Please read the corresponding pages for their job configuration files. The subsequent pages will illustrate the details on each component of the configuration.
If a user’s model contains some user-defined components, e.g., Updater, he has to write a main function to register these components. It is similar to Hadoop’s main function. Generally, the main function should
SINGA 초기화, e.g., setup logging.
유저 컴포넌트의 등록
job configuration 을 작성하고 SINGA driver 에서 설정
main 함수의 샘플입니다.
#include "singa.h" #include "user.h" // header for user code int main(int argc, char** argv) { singa::Driver driver; driver.Init(argc, argv); bool resume; // parse resume option from argv. // register user defined layers driver.RegisterLayer<FooLayer>(kFooLayer); // register user defined updater driver.RegisterUpdater<FooUpdater>(kFooUpdater); ... auto jobConf = driver.job_conf(); // update jobConf driver.Train(resume, jobConf); return 0; }
Driver class’ Init method 는 커맨드라인 인수 -conf <job conf> 에서 주어진 job configuration 파일을 읽습니다. 그 파일에는 cluster topology 정보가 기술 되어있고, 유저가 neural net, updater 등을 업데이트 혹은 설정 하기위한 jobConf를 리턴합니다. 유저가 Layer, Updater, Worker, Param 등의 subclass를 정의하면, driver 에 등록을 해야합니다. 트레이닝을 시작하기 위하여 job configuration 즉 jobConf를 driver.Train 에 넘겨줍니다.
We will provide helper functions to make the configuration easier in the future, like keras.
Users need to compile and link their code (e.g., layer implementations and the main file) with SINGA library (.libs/libsinga.so) to generate an executable file, e.g., with name mysinga. To launch the program, users just pass the path of the mysinga and base job configuration to ./bin/singa-run.sh.
./bin/singa-run.sh -conf <path to job conf> -exec <path to mysinga> [other arguments]
RNN application 에서 RNN 모델의 트레이닝을 위한 함수의 프로그램 예를 설명합니다.