Skip to content

Commit

Permalink
I think that I get pretty good at cifar-10, now it is time to impleme…
Browse files Browse the repository at this point in the history
…nt this on CUDA
  • Loading branch information
liuliu committed Oct 27, 2013
1 parent c385a5d commit aa202ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bin/cifar-10.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ int main(int argc, char** argv)
}
ccv_convnet_train_param_t params = {
.max_epoch = 100,
.mini_batch = 100,
.mini_batch = 128,
.decay = 0.005,
.learn_rate = 0.001,
.learn_rate = 0.0005,
.momentum = 0.9,
};
ccv_convnet_supervised_train(convnet, categorizeds, tests, params);
Expand Down
26 changes: 13 additions & 13 deletions lib/ccv_convnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ void ccv_convnet_supervised_train(ccv_convnet_t* convnet, ccv_array_t* categoriz
ccv_convnet_t* momentum = _ccv_convnet_update_new(convnet);
for (t = 0; t < params.max_epoch; t++)
{
printf(" - at epoch %d / %d\n", t + 1, params.max_epoch);
for (i = 0; i < aligned_rnum; i++)
{
// dropout the first hidden layer
Expand Down Expand Up @@ -846,24 +847,23 @@ void ccv_convnet_supervised_train(ccv_convnet_t* convnet, ccv_array_t* categoriz
_ccv_convnet_propagate_loss(convnet, categorized->matrix, softmax, update_params);
if ((i + 1) % params.mini_batch == 0)
{
printf("epoch %d\n", i);
FLUSH(" - stochastic gradient descent at %d / %d", (i + 1) / params.mini_batch, aligned_rnum / params.mini_batch);
// update weights
_ccv_convnet_update(convnet, momentum, update_params, params.momentum, params.learn_rate, params.decay);
_ccv_convnet_update_zero(update_params);
if ((i + 1) % 10000 == 0)
{
int miss = 0;
for (j = 0; j < tests->rnum; j++)
{
ccv_categorized_t* test = (ccv_categorized_t*)ccv_array_get(tests, j);
int c = ccv_convnet_classify(convnet, test->matrix);
if (c != test->c)
++miss;
}
printf("\n - miss rate : %.2f%%\n", miss * 100.0f / tests->rnum);
}
}
}
printf("\n");
int miss = 0;
for (i = 0; i < tests->rnum; i++)
{
FLUSH(" - going through %d / %d for tests", i + 1, tests->rnum);
ccv_categorized_t* test = (ccv_categorized_t*)ccv_array_get(tests, i);
int c = ccv_convnet_classify(convnet, test->matrix);
if (c != test->c)
++miss;
}
FLUSH(" - with miss rate %.2f%%\n", miss * 100.0f / tests->rnum);
if (t + 1 < params.max_epoch)
{
// reshuffle the parts we visited and move the rest to the beginning
Expand Down

0 comments on commit aa202ae

Please sign in to comment.