void do_more_stdin(FILE *fp) { char buffer[BUFFER_SIZE]; char *numByte; int wordSize; int toDelete; int linesDone = 0; while(!feof(fp)) { if(fgets(buffer, BUFFER_SIZE, fp)) { if(linesDone > 0) deleteSpace(toDelete + SIZE); numByte = buffer; wordSize = ((int)strlen(numByte) * sizeof(numByte) - BYTES) / BYTES; printf("%s", buffer); sprintf(buffer, "bytes %d", wordSize); numByte = buffer; printf("\033[7m %s \033[m", numByte); toDelete = ((int)strlen(numByte) * sizeof(numByte) - BYTES) / BYTES; memset(&buffer[0], 0, sizeof(buffer)); linesDone++; } } }
int see_more(FILE *cmd, char *buf) { int c; printf("\033[7m %s \033[m", buf); while((c = getc(cmd)) != EOF) { if(c == 'q') { deleteSpace((int)strlen(buf) + TWO); return 0; } if(c == ' ') { deleteSpace((int)strlen(buf) + TWO); return PAGELEN; } if(c == '\n') { deleteSpace((int)strlen(buf) + TWO); return 1; } } return SUCCESS; }
void Config::init(string path, SoftMax &SMR) { m_configStr = read_2_string(path); deleteComment(); deleteSpace(); get_layers_config(m_configStr,SMR); use_log = get_word_bool(m_configStr, "USE_LOG"); batch_size = get_word_int(m_configStr, "BATCH_SIZE"); non_linearity = get_word_type(m_configStr, "NON_LINEARITY"); training_epochs = get_word_int(m_configStr, "TRAINING_EPOCHS"); lrate_w = get_word_float(m_configStr, "LRATE_W"); lrate_b = get_word_float(m_configStr, "LRATE_B"); iter_per_epo = get_word_int(m_configStr, "ITER_PER_EPO"); ngram = get_word_int(m_configStr, "NGRAM"); training_percent = get_word_float(m_configStr, "TRAINING_PERCENT"); cout << "****************************************************************************" << endl << "** READ CONFIG FILE COMPLETE " << endl << "****************************************************************************" << endl << endl; for (int i = 0; i < HiddenConfigs.size(); i++) { cout << "***** hidden layer: " << i << " *****" << endl; cout << "NumHiddenNeurons = " << HiddenConfigs[i].get_NeuronNum() << endl; cout << "WeightDecay = " << HiddenConfigs[i].get_WeightDecay() << endl; cout << "DropoutRate = " << HiddenConfigs[i].get_DropoutRate() << endl << endl; } cout << "***** softmax layer: *****" << endl; // cout<<"NumClasses = "<<softmaxConfig.NumClasses<<endl; cout << "WeightDecay = " << SMR.get_WeightDecay() << endl << endl; cout << "***** general config *****" << endl; cout << "use_log = " << use_log << endl; cout << "batch size = " << batch_size << endl; cout << "non-linearity method = " << non_linearity << endl; cout << "training epochs = " << training_epochs << endl; cout << "learning rate for weight matrices = " << lrate_w << endl; cout << "learning rate for bias = " << lrate_b << endl; cout << "iteration per epoch = " << iter_per_epo << endl; cout << "ngram = " << ngram << endl; cout << "training percent = " << training_percent << endl; cout << endl; }
void Memory::initialize(const std::string & str) { std::ifstream ifs(str); std::string s; if (ifs.fail()) { std::cerr << str + " does not exist." << std::endl; exit(0); } int i = 0; while(std::getline(ifs, s)) { s = deleteSpace(s); s = deleteComment(s); if (s.size() == 0) { continue; } memory[i] = s; i++; } int size = memory.size(); for (; i < size; i++) { memory[i] = "0000000000000000"; } }
static int CreateMaxSpaces(void) { int res = 1, i = 0; int max; L4_Word_t result, end; L4_SpaceId_t space; okl4_allocator_attr_t attr; while(res == 1) { result = okl4_kspaceid_allocany(spaceid_pool, &space); fail_unless(result == OKL4_OK, "Failed to allocate any space id."); res = create_address_space(space, L4_Fpage(0xb10000, 0x1000)); if(res != 1) break; /* 2gb mapping of 512k pages*/ res = map_series(space, 0x80000, 4096, 0, 0); i++; } max = i; /* clean up */ okl4_kspaceid_getattribute(spaceid_pool, &attr); end = attr.base + attr.size; for (i = attr.base; i < end; i++) { L4_SpaceId_t id = L4_SpaceId(i); if (okl4_kspaceid_isallocated(spaceid_pool, id) && id.space_no != KTEST_SPACE.space_no) { deleteSpace(id); } } return max; }