- Timestamp:
- Dec 29, 2021, 5:52:00 PM (3 years ago)
- Branches:
- feature/crepe
- Children:
- 557e0a7
- Parents:
- 9b05ea9
- git-author:
- Paul Brossier <piem@piem.org> (01/18/19 10:47:14)
- git-committer:
- Paul Brossier <piem@piem.org> (12/29/21 17:52:00)
- Location:
- src/ai
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/batchnorm.c
r9b05ea9 r72f450a 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 -
src/ai/batchnorm.h
r9b05ea9 r72f450a 41 41 typedef struct _aubio_batchnorm_t aubio_batchnorm_t; 42 42 43 aubio_batchnorm_t *new_aubio_batchnorm( uint_t n_outputs);43 aubio_batchnorm_t *new_aubio_batchnorm(void); 44 44 45 45 void aubio_batchnorm_do(aubio_batchnorm_t *t,
Note: See TracChangeset
for help on using the changeset viewer.