static Network* setupTestNetwork( void ) { Network *network; int i; network = makeNetwork( 2, 2, 2 ); for( i = 0; i < 8; ++i ) { network->hiddenWeights[i] = i; } return network; }
static void makeNetwork_test( void ) { Network *network; int i; network = makeNetwork( 8, 5, 8 ); assert( network != NULL && "Should have properly allocated" ); assert( network->hiddenWeights != NULL && "Should have properly allocated" ); assert( network->outputWeights != NULL && "Should have properly allocated" ); assert( network->testInputs != NULL && "Should have properly allocated" ); assert( network->testOutputs != NULL && "Should have properly allocated" ); assert( network->input == 8 ); assert( network->hidden == 5 ); assert( network->output == 8 ); assert( network->outputWeights == network->hiddenWeights + 40 ); assert( network->testInputs == network->hiddenWeights + 80 ); assert( network->testOutputs == network->hiddenWeights + 88 ); for( i = 0; i < 50; ++i ) { assert( network->hiddenWeights[i] != 0 ); assert( network->outputWeights[i] != 0 ); } network = makeNetwork( 5, 50, 5 ); assert( network == NULL && "Should have not been able to allocate" ); }
int main(int argc, char** argv) { ifstream fin(argv[1],ios::in); int ngenes = 133772; int nsamples = 160; cout<<"make matrix"<<endl; mat Data = makeMatrix(fin, ngenes, nsamples); cout<<"finish making matrix"<<endl; uvec tumor(80), ctrl(80); for(int i=0; i<80; i++){ tumor(i) = 2*i; ctrl(i) = 2*i+1; } mat tumorData = Data.cols(tumor); mat ctrlData = Data.cols(ctrl); tumorData = tumorData.t(); ctrlData = ctrlData.t(); //init boostup int nb = 100; int iter = 0; set<int> res; uvec sample(10); randomSample(sample, 10000+iter, 0, 79); mat tumorSample = tumorData.rows(sample); mat ctrlSample = ctrlData.rows(sample); network test(100000); makeNetwork(test, ctrlSample, 0.75); cout<<"successfully make network"<<endl; //到makeNetwork才会出现问题; /* double thes = 0.75; mat net1 = makeNetwork(tumorSample, thes); mat net2 = makeNetwork(ctrlSample, thes); cout<<"first statage"<<endl; mat resnet = mergeNetwork(net1, net2); uvec indices = find(resnet==1); res = getGeneSet(indices, 10); iter++; set<int>::iterator it_test = res.begin(); for(;it_test != res.end(); it_test++) cout<<*it_test<<" "; cout<<endl; while(iter < nb){ randomSample(sample, 10000+iter, 0,79); tumorSample = tumorData.rows(sample); ctrlSample = ctrlData.rows(sample); net1 = makeNetwork(tumorSample, thes); net2 = makeNetwork(ctrlSample, thes); resnet = mergeNetwork(net1, net2); indices = find(resnet==1); set<int> tmpset = getGeneSet(indices, 10); set_intersection(tmpset.begin(),tmpset.end(),res.begin(),res.end(), inserter(res, res.end())); iter++; } cout<<"after boostrap:"<<endl; for(it_test=res.begin();it_test!=res.end();it_test++) cout<<*it_test<<" "; cout<<endl; */ return 0; }