Changeset 689ba93 for src/ai/batchnorm.c
- Timestamp:
- Jan 18, 2019, 10:47:14 AM (6 years ago)
- Branches:
- feature/crepe_org
- Children:
- e75a48e
- Parents:
- 3977b4f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/batchnorm.c
r3977b4f r689ba93 35 35 aubio_tensor_t *input_tensor); 36 36 37 aubio_batchnorm_t *new_aubio_batchnorm( uint_t n_outputs)37 aubio_batchnorm_t *new_aubio_batchnorm(void) 38 38 { 39 39 aubio_batchnorm_t *c = AUBIO_NEW(aubio_batchnorm_t); 40 41 AUBIO_GOTO_FAILURE((sint_t)n_outputs > 0);42 43 c->n_outputs = n_outputs;44 45 c->gamma = new_fvec(n_outputs);46 c->beta = new_fvec(n_outputs);47 c->moving_mean = new_fvec(n_outputs);48 c->moving_variance = new_fvec(n_outputs);49 50 40 return c; 51 41 #if 0 // no argument so no other possible failure 52 42 failure: 53 43 del_aubio_batchnorm(c); 54 44 return NULL; 45 #endif 55 46 } 56 47 57 void del_aubio_batchnorm(aubio_batchnorm_t*c) {48 static void aubio_batchnorm_reset(aubio_batchnorm_t *c) { 58 49 AUBIO_ASSERT(c); 59 50 if (c->gamma) … … 65 56 if (c->moving_variance) 66 57 del_fvec(c->moving_variance); 58 } 59 60 void del_aubio_batchnorm(aubio_batchnorm_t* c) { 61 aubio_batchnorm_reset(c); 67 62 AUBIO_FREE(c); 68 63 } … … 82 77 83 78 AUBIO_ASSERT(c && input && shape); 84 AUBIO_ASSERT(c->n_outputs == input->shape[input->ndim - 1]);85 79 86 80 for (i = 0; i < input->ndim; i++) { 87 81 shape[i] = input->shape[i]; 82 } 83 84 aubio_batchnorm_reset(c); 85 86 c->n_outputs = input->shape[input->ndim - 1]; 87 88 c->gamma = new_fvec(c->n_outputs); 89 c->beta = new_fvec(c->n_outputs); 90 c->moving_mean = new_fvec(c->n_outputs); 91 c->moving_variance = new_fvec(c->n_outputs); 92 93 if (!c->gamma || !c->beta || !c->moving_mean || !c->moving_variance) 94 { 95 aubio_batchnorm_reset(c); 96 return AUBIO_FAIL; 88 97 } 89 98
Note: See TracChangeset
for help on using the changeset viewer.