Skip to content

Commit

Permalink
Adding -c flag to usage help
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardicus committed Dec 23, 2019
1 parent da07da4 commit a398d4a
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set_t set;

static int write_output_directly_bytes = 0;
static char *read_network = NULL;
static char *seed = NULL;

void store_the_net_layers(int signo)
{
Expand Down Expand Up @@ -66,6 +67,7 @@ void usage(char *argv[]) {
printf(" -L : Number of layers, may not exceed %d\r\n", LSTM_MAX_LAYERS);
printf(" -N : Number of neurons in every layer\r\n");
printf(" -vr : Verbosity level. Set to zero and only the loss function after and not during training will be printed.\n");
printf(" -c : Don't train, only generate output. Seed given by the value. If -r is used, datafile is not considered.\r\n");
printf("\r\n");
printf("Check std_conf.h to see what default values are used, these are set during compilation.\r\n");
printf("\r\n");
Expand Down Expand Up @@ -127,6 +129,8 @@ void parse_input_args(int argc, char** argv)
}
} else if ( !strcmp(argv[a], "-vr") ) {
params.print_progress = !!atoi(argv[a+1]);
} else if ( !strcmp(argv[a], "-c") ) {
seed = argv[a+1];
}

a += 2;
Expand Down Expand Up @@ -243,42 +247,47 @@ int main(int argc, char *argv[])

lstm_load(read_network, &set, &params, &model_layers);

FRead = set_get_features(&set);
if ( seed == NULL ) {

// Read from datafile, see if new features appear
FRead = set_get_features(&set);

fp = fopen(argv[1], "r");
if ( fp == NULL ) {
printf("Could not open file: %s\n", argv[1]);
return -1;
}
// Read from datafile, see if new features appear

while ( ( c = fgetc(fp) ) != EOF ) {
set_insert_symbol(&set, (char)c );
}
fp = fopen(argv[1], "r");
if ( fp == NULL ) {
printf("Could not open file: %s\n", argv[1]);
return -1;
}

while ( ( c = fgetc(fp) ) != EOF ) {
set_insert_symbol(&set, (char)c );
}

fclose(fp);
fclose(fp);

FReadNewAfterDataFile = set_get_features(&set);
FReadNewAfterDataFile = set_get_features(&set);

if ( FReadNewAfterDataFile > FRead ) {
// New features appeared. Must change
// first and last layer.
printf("New features detected in datafile.\nLoaded network worked with %d features\
if ( FReadNewAfterDataFile > FRead ) {
// New features appeared. Must change
// first and last layer.
printf("New features detected in datafile.\nLoaded network worked with %d features\
, now there is %d features in total.\n\
Reallocating space in network input and output layer to accommodate this new feature set.\n",
FRead, FReadNewAfterDataFile);
FRead, FReadNewAfterDataFile);

lstm_reinit_model(
model_layers,
params.layers,
FRead,
FReadNewAfterDataFile
);
lstm_reinit_model(
model_layers,
params.layers,
FRead,
FReadNewAfterDataFile
);

}

}

printf("Loaded the net: %s\n", read_network);
if ( seed == NULL )
printf("Loaded the net: %s\n", read_network);
} else {
/* Allocating space for a new model */
model_layers = calloc(params.layers, sizeof(lstm_model_t*));
Expand Down Expand Up @@ -328,15 +337,9 @@ Reallocating space in network input and output layer to accommodate this new fea
usage(argv);
}

if ( argc >= 6 && !strcmp(argv[4], "-c") ) {

do {
clean = strchr(argv[5], '_');
if ( clean != NULL )
*clean = ' ';
} while ( clean != NULL );

lstm_output_string_from_string(model_layers, &set, argv[5], params.layers, 128);
if ( seed != NULL ) {
// output directly
lstm_output_string_from_string(model_layers, &set, seed, params.layers, 256);

} else {
double loss;
Expand Down

0 comments on commit a398d4a

Please sign in to comment.