Exemple #1
0
int main (int argc, char *argv[])
{
  Array breakPoints;
  BreakPoint *currBP;
  int i;
  char *breakPointSequence;

  if ((Conf = confp_open(getenv("FUSIONSEQ_CONFPATH"))) == NULL)
    return EXIT_FAILURE;

  bp_init ("-");
  breakPoints = bp_getBreakPoints ();
  arraySort (breakPoints,(ARRAYORDERF)sortBreakPointsByTargetAndOffset);
  
  for (i = 0; i < arrayMax (breakPoints); i++) {
    currBP = arrp (breakPoints,i,BreakPoint);
    breakPointSequence = getBreakPointSequence (currBP->tileCoordinate1,currBP->tileCoordinate2);
    printf( ">%s|%s\n%s\n", currBP->tileCoordinate1, currBP->tileCoordinate2, breakPointSequence);
    warn(">%s|%s\n%s", 
	 currBP->tileCoordinate1, 
	 currBP->tileCoordinate2, 
	 subString(breakPointSequence, 10, strlen(breakPointSequence)-10));
  }
  bp_deInit();
  confp_close(Conf);

  return EXIT_SUCCESS;
}
Exemple #2
0
static void test_backprop_update()
{
    bp net;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int hidden_layers=2;
    int no_of_outputs=5;
    int i;
    unsigned int random_seed = 123;

    printf("test_backprop_update...");

    bp_init(&net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert((&net)->inputs!=0);
    assert((&net)->hiddens!=0);
    assert((&net)->outputs!=0);

    /* set some inputs */
    for (i = 0; i < no_of_inputs; i++) {
        bp_set_input(&net, i, i/(float)no_of_inputs);
    }

    for (i = 0; i < 100; i++) {
        bp_update(&net,0);
    }

    bp_free(&net);

    printf("Ok\n");
}
Exemple #3
0
/**
* @brief Generates an autocoder for the given neural net layer
* @param net Backprop neural net object
* @param hidden_layer The layer within the neural net to be autocoded
* @param autocoder Autocoder neural net object
*/
void bp_create_autocoder(bp * net,
                         int hidden_layer,
                         bp * autocoder)
{
    /* number of inputs for the autocoder is the same as
        the number of hidden units */
    int no_of_inputs = net->NoOfHiddens;

    if (hidden_layer == 0) {
        /* if this is the first hidden layer then number of inputs
            for the autocoder is the same as the number of
            neural net input units */
        no_of_inputs = net->NoOfInputs;
    }

    /* create the autocoder */
    bp_init(autocoder,
            no_of_inputs,
            net->NoOfHiddens,1,
            no_of_inputs,
            &net->random_seed);

    /* assign parameters to the autocoder */
    autocoder->DropoutPercent = net->DropoutPercent;
    autocoder->learningRate = net->learningRate;
}
Exemple #4
0
void DEBUG_Init(s32 device_type,s32 channel_port)
{
    u32 level;
    struct uip_ip_addr localip,netmask,gateway;

    UIP_LOG("DEBUG_Init()\n");

    __lwp_thread_dispatchdisable();

    bp_init();

    if(device_type==GDBSTUB_DEVICE_USB) {
        current_device = usb_init(channel_port);
    } else {
        localip.addr = uip_ipaddr((const u8_t*)tcp_localip);
        netmask.addr = uip_ipaddr((const u8_t*)tcp_netmask);
        gateway.addr = uip_ipaddr((const u8_t*)tcp_gateway);

        current_device = tcpip_init(&localip,&netmask,&gateway,(u16)channel_port);
    }

    if(current_device!=NULL) {
        _CPU_ISR_Disable(level);
        __exception_sethandler(EX_DSI,dbg_exceptionhandler);
        __exception_sethandler(EX_PRG,dbg_exceptionhandler);
        __exception_sethandler(EX_TRACE,dbg_exceptionhandler);
        __exception_sethandler(EX_IABR,dbg_exceptionhandler);
        _CPU_ISR_Restore(level);

        dbg_initialized = 1;

    }
    __lwp_thread_dispatchenable();
}
Exemple #5
0
static void test_backprop()
{
    bp net;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int hidden_layers=2;
    int no_of_outputs=5;
    int i,l;
    unsigned int random_seed = 123;

    printf("test_backprop...");

    bp_init(&net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert((&net)->inputs!=0);
    assert((&net)->hiddens!=0);
    assert((&net)->outputs!=0);

    /* set some inputs */
    for (i = 0; i < no_of_inputs; i++) {
        bp_set_input(&net, i, i/(float)no_of_inputs);
        (&net)->inputs[i]->BPerror = 999;
    }
    for (l = 0; l < hidden_layers; l++) {
        for (i = 0; i < bp_hiddens_in_layer(&net,l); i++) {
            (&net)->hiddens[l][i]->BPerror = 999;
        }
    }
    /* set some target outputs */
    for (i = 0; i < no_of_outputs; i++) {
        (&net)->outputs[i]->BPerror = 999;
        bp_set_output(&net, i, i/(float)no_of_inputs);
    }

    /* feed forward */
    bp_feed_forward(&net);
    bp_backprop(&net,0);

    /* check for non-zero backprop error values */
    for (i = 0; i < no_of_inputs; i++) {
        assert((&net)->inputs[i]->BPerror != 999);
    }
    for (l = 0; l < hidden_layers; l++) {
        for (i = 0; i < bp_hiddens_in_layer(&net,l); i++) {
            assert((&net)->hiddens[l][i]->BPerror != 999);
        }
    }
    for (i = 0; i < no_of_outputs; i++) {
        assert((&net)->outputs[i]->BPerror != 999);
    }

    bp_free(&net);

    printf("Ok\n");
}
Exemple #6
0
static void test_backprop_inputs_from_image()
{
    bp net;
    int image_width=10;
    int image_height=10;
    int x,y,i=0;
    unsigned char * img;
    int no_of_inputs=image_width*image_height;
    int no_of_hiddens=4*4;
    int hidden_layers=2;
    int no_of_outputs=2*2;
    unsigned int random_seed = 123;

    printf("test_backprop_inputs_from_image...");

    /* create a mono image */
    img = (unsigned char*)malloc(image_width*image_height);
    for (y = 0; y < image_height; y++) {
        for (x = 0; x < image_width; x++,i++) {
            img[i] = i%256;
        }
    }

    /* create a network */
    bp_init(&net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert((&net)->inputs!=0);
    assert((&net)->hiddens!=0);
    assert((&net)->outputs!=0);

    /* set inputs to zero */
    for (i = 0; i < no_of_inputs; i++) {
        (&net)->inputs[i]->value = 0;
    }

    /* insert the image into the input units */
    bp_inputs_from_image(&net, img, image_width, image_height);

    /* check that the imputs are within range */
    for (i = 0; i < no_of_inputs; i++) {
        assert((&net)->inputs[i]->value > 0.1f);
        assert((&net)->inputs[i]->value < 0.9f);
    }

    /* free the memory */
    free(img);
    bp_free(&net);

    printf("Ok\n");
}
Exemple #7
0
int main (int argc, char *argv[])
{
	Array breakPoints;
	BreakPoint *currBP;
	BreakPointRead *currBPR;
	int i,j,k;
	int readLength;
	int tileSize;
	char *breakPointSequence;

	if ((Conf = confp_open(getenv("FUSIONSEQ_CONFPATH"))) == NULL)
		return EXIT_FAILURE;

	bp_init ("-");
	breakPoints = bp_getBreakPoints ();
	for (i = 0; i < arrayMax (breakPoints); i++) {
		currBP = arrp (breakPoints,i,BreakPoint);
		tileSize = getTileSize (currBP->tileCoordinate1,currBP->tileCoordinate2);
		breakPointSequence = getBreakPointSequence (currBP->tileCoordinate1,currBP->tileCoordinate2);
		printf ("Tile 1: %s\n",currBP->tileCoordinate1);
		printf ("Tile 2: %s\n",currBP->tileCoordinate2);
		printf ("Number of reads spanning breakpoint: %d\n\n\n",arrayMax (currBP->breakPointReads));
		for (j = 0; j < arrayMax (currBP->breakPointReads); j++) {
			currBPR = arrp (currBP->breakPointReads,j,BreakPointRead);
			readLength = strlen (currBPR->read);
			for (k = 0; k < currBPR->offset; k++) {
				printf (" ");
			}
			for (k = 0; k < readLength; k++) {
				if (((currBPR->offset + k) % tileSize) == 0 && (currBPR->offset + k) != 0) {
					printf ("%s",TILE_SEPARATOR);
				}
				printf ("%c",currBPR->read[k]);
			}
			printf ("\n");
		}
		for (k = 0; k < (2 * tileSize); k++) {
			if ((k % tileSize) == 0 && k != 0) {
				printf ("%s",TILE_SEPARATOR);
			}
			printf ("%c",breakPointSequence[k]);
		}
		printf ("\n\n\n\n\n");
	}
	bp_deInit ();

	confp_close(Conf);

	return EXIT_SUCCESS;
}
Exemple #8
0
static void test_backprop_autocoder()
{
    bp autocoder;
    int itt,i,j;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int no_of_outputs=10;
    unsigned int random_seed = 123;
    float tot;

    printf("test_backprop_autocoder...");

    /* create the autocoder */
    bp_init(&autocoder,
            no_of_inputs,
            no_of_hiddens,1,
            no_of_outputs,
            &random_seed);

    autocoder.learningRate = 0.5f;

    /* run the autocoder for some itterations */
    for (itt = 0; itt < 100; itt++) {
        /* set the inputs */
        for (i = 0; i < no_of_inputs; i++) {
            bp_set_input(&autocoder,i,0.25f + (i*0.5f/(float)no_of_inputs));
            bp_set_output(&autocoder,i,0.75f - (i*0.5f/(float)no_of_inputs));
        }
        /* update */
        bp_update(&autocoder,0);
    }

    for (i = 0; i < no_of_hiddens; i++) {
        /* check that some errors have been back-propogated */
        assert((&autocoder)->hiddens[0][i]->BPerror != 0);
        /* check that weights have changed */
        tot = 0;
        for (j = 0; j < no_of_inputs; j++) {
            assert((&autocoder)->hiddens[0][i]->lastWeightChange[j]!=0);
            tot += fabs((&autocoder)->hiddens[0][i]->lastWeightChange[j]);
        }
        /* total weight change */
        assert(tot > 0.00001f);
    }

    bp_free(&autocoder);

    printf("Ok\n");
}
Exemple #9
0
static void test_backprop_save_load()
{
    bp net1, net2;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int no_of_outputs=3;
    int hidden_layers=3;
    int retval;
    unsigned int random_seed = 123;
    char filename[256];
    FILE * fp;

    printf("test_backprop_save_load...");

    /* create network */
    bp_init(&net1,
            no_of_inputs, no_of_hiddens,
            hidden_layers, no_of_outputs,
            &random_seed);

    sprintf(filename,"%stemp_deep.dat",DEEPLEARN_TEMP_DIRECTORY);

    /* save the first network */
    fp = fopen(filename,"wb");
    assert(fp!=0);
    bp_save(fp, &net1);
    fclose(fp);

    /* load into the second network */
    fp = fopen(filename,"rb");
    assert(fp!=0);
    bp_load(fp, &net2, &random_seed);
    fclose(fp);

    /* compare the two */
    retval = bp_compare(&net1, &net2);
    if (retval<1) {
        printf("\nretval = %d\n",retval);
    }
    assert(retval==1);

    /* free memory */
    bp_free(&net1);
    bp_free(&net2);

    printf("Ok\n");
}
Exemple #10
0
static void test_backprop_deep()
{
    bp net;
    bp autocoder;
    int l,itt,i;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int hidden_layers=3;
    int no_of_outputs=2;
    unsigned int random_seed = 123;

    printf("test_backprop_deep...");

    bp_init(&net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert((&net)->inputs!=0);
    assert((&net)->hiddens!=0);
    assert((&net)->outputs!=0);

    for (l = 0; l < hidden_layers; l++) {
        /* create an autocoder for this layer */
        bp_create_autocoder(&net,l,&autocoder);
        /* do some training */
        for (itt = 0; itt < 100; itt++) {
            /* set the inputs */
            for (i = 0; i < no_of_inputs; i++) {
                bp_set_input(&net,i,i/(float)no_of_inputs);
            }
            /* update */
            bp_pretrain(&net,&autocoder,l);
        }
        /* move the autocoder hidden weights into the main network */
        bp_update_from_autocoder(&net,&autocoder,l);
        /* delete the autocoder */
        bp_free(&autocoder);
    }

    bp_free(&net);

    printf("Ok\n");
}
Exemple #11
0
/**
* @brief Load a network from file
* @brief fp File pointer
* @param net Backprop neural net object
* @param random_seed Random number generator seed
*/
int bp_load(FILE * fp, bp * net,
            unsigned int * random_seed)
{
    int retval,i,l;
    int no_of_inputs=0, no_of_hiddens=0, no_of_outputs=0;
    int hidden_layers=0;
    float learning_rate=0, noise=0, BPerrorAverage=0;
    float DropoutPercent=0;
    unsigned int itterations=0;

    retval = fread(&itterations, sizeof(unsigned int), 1, fp);
    retval = fread(&no_of_inputs, sizeof(int), 1, fp);
    retval = fread(&no_of_hiddens, sizeof(int), 1, fp);
    retval = fread(&no_of_outputs, sizeof(int), 1, fp);
    retval = fread(&hidden_layers, sizeof(int), 1, fp);
    retval = fread(&learning_rate, sizeof(float), 1, fp);
    retval = fread(&noise, sizeof(float), 1, fp);
    retval = fread(&BPerrorAverage, sizeof(float), 1, fp);
    retval = fread(&DropoutPercent, sizeof(float), 1, fp);

    bp_init(net, no_of_inputs, no_of_hiddens,
            hidden_layers, no_of_outputs,
            random_seed);

    for (l = 0; l < net->HiddenLayers; l++) {
        for (i = 0; i < net->NoOfHiddens; i++) {
            bp_neuron_load(fp,net->hiddens[l][i]);
        }
    }
    for (i = 0; i < net->NoOfOutputs; i++) {
        bp_neuron_load(fp,net->outputs[i]);
    }

    net->learningRate = learning_rate;
    net->noise = noise;
    net->BPerrorAverage = BPerrorAverage;
    net->BPerror = BPerrorAverage;
    net->BPerrorTotal = BPerrorAverage;
    net->itterations = itterations;
    net->DropoutPercent = DropoutPercent;

    return retval;
}
Exemple #12
0
static void test_backprop_feed_forward()
{
    bp net;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int hidden_layers=2;
    int no_of_outputs=5;
    int i;
    unsigned int random_seed = 123;

    printf("test_backprop_feed_forward...");

    bp_init(&net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert((&net)->inputs!=0);
    assert((&net)->hiddens!=0);
    assert((&net)->outputs!=0);

    /* set some inputs */
    for (i = 0; i < no_of_inputs; i++) {
        bp_set_input(&net, i, i/(float)no_of_inputs);
    }
    /* clear the outputs */
    for (i = 0; i < no_of_outputs; i++) {
        (&net)->outputs[i]->value = 999;
    }

    /* feed forward */
    bp_feed_forward(&net);

    /* check for non-zero outputs */
    for (i = 0; i < no_of_outputs; i++) {
        assert((&net)->outputs[i]->value != 999);
    }

    bp_free(&net);

    printf("Ok\n");
}
Exemple #13
0
static void test_backprop_init()
{
    bp net;
    int no_of_inputs=10;
    int no_of_hiddens=4;
    int hidden_layers=2;
    int no_of_outputs=2;
    unsigned int random_seed = 123;

    printf("test_backprop_init...");

    bp_init(&net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert((&net)->inputs!=0);
    assert((&net)->hiddens!=0);
    assert((&net)->outputs!=0);
    bp_free(&net);

    printf("Ok\n");
}
Exemple #14
0
static void test_backprop_training()
{
    bp * net;
    int no_of_inputs=2;
    int no_of_hiddens=2;
    int hidden_layers=1;
    int no_of_outputs=1;
    int itt,example;
    unsigned int random_seed = 123;
    float state_TRUE = 0.8f;
    float state_FALSE = 0.2f;

    printf("test_backprop_training...");

    net = (bp*)malloc(sizeof(bp));
    bp_init(net,
            no_of_inputs, no_of_hiddens,
            hidden_layers,
            no_of_outputs, &random_seed);
    assert(net->inputs!=0);
    assert(net->hiddens!=0);
    assert(net->outputs!=0);

    /* training */
    example=0;
    for (itt = 0; itt < 500000; itt++, example++) {
        if (example>=4) example=0;

        /* select an example from the XOR truth table */
        switch(example) {
        case 0: {
            bp_set_input(net, 0, state_FALSE);
            bp_set_input(net, 1, state_FALSE);
            bp_set_output(net, 0, state_FALSE);
            break;
        }
        case 1: {
            bp_set_input(net, 0, state_TRUE);
            bp_set_input(net, 1, state_FALSE);
            bp_set_output(net, 0, state_TRUE);
            break;
        }
        case 2: {
            bp_set_input(net, 0, state_FALSE);
            bp_set_input(net, 1, state_TRUE);
            bp_set_output(net, 0, state_TRUE);
            break;
        }
        case 3: {
            bp_set_input(net, 0, state_TRUE);
            bp_set_input(net, 1, state_TRUE);
            bp_set_output(net, 0, state_FALSE);
            break;
        }
        }

        /* train on the example */
        bp_update(net,0);
    }

    bp_set_input(net, 0, state_FALSE);
    bp_set_input(net, 1, state_FALSE);
    bp_feed_forward(net);
    if (bp_get_output(net, 0) >= 0.5f) {
        printf("\n%.5f\n",bp_get_output(net, 0));
    }
    assert(bp_get_output(net, 0) < 0.5f);

    bp_set_input(net, 0, state_FALSE);
    bp_set_input(net, 1, state_TRUE);
    bp_feed_forward(net);
    if (bp_get_output(net, 0) <= 0.5f) {
        printf("\n%.5f\n",bp_get_output(net, 0));
    }
    assert(bp_get_output(net, 0) > 0.5f);

    bp_set_input(net, 0, state_TRUE);
    bp_set_input(net, 1, state_FALSE);
    bp_feed_forward(net);
    if (bp_get_output(net, 0) <= 0.5f) {
        printf("\n%.5f\n",bp_get_output(net, 0));
    }
    assert(bp_get_output(net, 0) > 0.5f);

    bp_set_input(net, 0, state_FALSE);
    bp_set_input(net, 1, state_FALSE);
    bp_feed_forward(net);
    if (bp_get_output(net, 0) >= 0.5f) {
        printf("\n%.5f\n",bp_get_output(net, 0));
    }
    assert(bp_get_output(net, 0) < 0.5f);

    bp_free(net);
    free(net);

    printf("Ok\n");
}
Exemple #15
0
int main(int argc, char *argv[])
{
	Array breakPoints;
	BreakPoint *currBP;
	BreakPointRead *currBPR;
	int minNumReads, minNumUniqueOffsets,
	    minNumReadsForKS,numPossibleOffsets;
	double pValueCutoffForKS;
	Array offsets;
	Array randomNumbers;
	double *observedOffsets;
	double *randomOffsets;

 	if (argc != 6) {
		usage((char*) "%s <minNumReads> <minNumUniqueOffsets> "
              "<minNumReadsForKS> <pValueCutoffForKS> <numPossibleOffsets>", 
              argv[0]);
    }
	
	minNumReads         = std::atoi(argv[1]);
	minNumUniqueOffsets = std::atoi(argv[2]);
	minNumReadsForKS    = std::atoi(argv[3]);
	pValueCutoffForKS   = std::atof(argv[4]);
	numPossibleOffsets  = std::atoi(argv[5]);
	bp_init("-");
	offsets = arrayCreate(100, int);
	randomNumbers = arrayCreate(100, int);
	breakPoints = bp_getBreakPoints();

	for (int i = 0; i < arrayMax(breakPoints); i++) {
		currBP = arrp(breakPoints, i, BreakPoint);
		arrayClear(offsets);
		for (int j = 0; j < arrayMax(currBP->breakPointReads); j++) {
			currBPR = arrp(currBP->breakPointReads, j, BreakPointRead);
			array(offsets, arrayMax(offsets), int) = currBPR->offset;
		}
		arraySort(offsets, (ARRAYORDERF) arrayIntcmp);
		arrayUniq(offsets, NULL, (ARRAYORDERF) arrayIntcmp);
		if (arrayMax(currBP->breakPointReads) >= minNumReads && 
		    arrayMax(currBP->breakPointReads) < minNumReadsForKS) {        
			if (arrayMax(offsets) >= minNumUniqueOffsets)
				std::puts(bp_writeBreakPoint(currBP));
		}
		else if (arrayMax(currBP->breakPointReads) >= minNumReads && 
			 arrayMax(currBP->breakPointReads) >= minNumReadsForKS) {
			arrayClear(randomNumbers);
			for (int j = 0; j < arrayMax(offsets); j++)
				array(randomNumbers, arrayMax(randomNumbers), int) = std::rand() % numPossibleOffsets;
			
			arraySort(randomNumbers, (ARRAYORDERF) arrayIntcmp);
			observedOffsets = (double *) hlr_malloc(arrayMax(offsets) * sizeof(double)); 
			randomOffsets = (double *) hlr_malloc(arrayMax(offsets) * sizeof(double)); 
			for (int j = 0; j < arrayMax(offsets); j++) {
				observedOffsets[j] = arru(offsets, j, int);
				randomOffsets[j] = arru(randomNumbers, j, int);
			}
			if (pValueCutoffForKS < TMath::KolmogorovTest(arrayMax(offsets), 
								      observedOffsets, 
								      arrayMax(offsets), 
								      randomOffsets, 
								      ""))
				std::puts(bp_writeBreakPoint(currBP));
			
			hlr_free(observedOffsets);
			hlr_free(randomOffsets);
		}
	}