Changeset 7f270f8 for src/ai/batchnorm.h
- Timestamp:
- Dec 29, 2021, 5:52:00 PM (3 years ago)
- Branches:
- feature/crepe
- Children:
- e7779f0
- Parents:
- e75bd80
- git-author:
- Paul Brossier <piem@piem.org> (01/24/19 00:24:14)
- git-committer:
- Paul Brossier <piem@piem.org> (12/29/21 17:52:00)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/batchnorm.h
re75bd80 r7f270f8 22 22 #define AUBIO_BATCHNORM_H 23 23 24 #ifdef __cplusplus25 extern "C" {26 #endif27 28 24 /** \file 29 25 … … 39 35 */ 40 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /** batch normalization layer */ 41 42 typedef struct _aubio_batchnorm_t aubio_batchnorm_t; 42 43 44 /** create a new batch normalization layer 45 46 This layer takes no parameters. The number of output channels will be 47 determined as the inner-most dimension of the input tensor when calling 48 ::aubio_batchnorm_get_output_shape. 49 50 */ 43 51 aubio_batchnorm_t *new_aubio_batchnorm(void); 44 52 45 void aubio_batchnorm_do(aubio_batchnorm_t *t, 46 aubio_tensor_t *input_tensor, 47 aubio_tensor_t *activations); 53 /** get output shape of the layer 48 54 49 uint_t aubio_batchnorm_set_gamma(aubio_batchnorm_t *t, fvec_t *gamma); 50 uint_t aubio_batchnorm_set_beta(aubio_batchnorm_t *t, fvec_t *beta); 51 uint_t aubio_batchnorm_set_moving_mean(aubio_batchnorm_t *t, fvec_t *moving_mean); 52 uint_t aubio_batchnorm_set_moving_variance(aubio_batchnorm_t *t, fvec_t *moving_variance); 55 \param t ::aubio_batchnorm_t layer 56 \param input input tensor 57 \param shape output shape 53 58 54 fvec_t *aubio_batchnorm_get_gamma(aubio_batchnorm_t *t); 55 fvec_t *aubio_batchnorm_get_beta(aubio_batchnorm_t *t); 56 fvec_t *aubio_batchnorm_get_moving_mean(aubio_batchnorm_t *t); 57 fvec_t *aubio_batchnorm_get_moving_variance(aubio_batchnorm_t *t); 59 This function determines the number of output channels required and allocate 60 the vectors of weights. The ouptut shape of this layer is identical to the 61 input shape. 58 62 63 */ 59 64 uint_t aubio_batchnorm_get_output_shape(aubio_batchnorm_t *t, 60 65 aubio_tensor_t *input, uint_t *shape); 61 66 67 /** get a pointer to the gamma vector 68 69 \param t ::aubio_batchnorm_t layer 70 71 \return pointer to `fvec_t` holding the gamma parameters 72 73 When called after ::aubio_batchnorm_get_output_shape, this function will 74 return a pointer to the vector allocated to hold the `gamma` weights. 75 76 A NULL pointer will be returned if ::aubio_batchnorm_get_output_shape has not 77 been called yet. 78 79 */ 80 fvec_t *aubio_batchnorm_get_gamma(aubio_batchnorm_t *t); 81 82 /** get a pointer to the beta vector 83 84 \param t ::aubio_batchnorm_t layer 85 86 \return pointer to `fvec_t` holding the beta parameters 87 */ 88 fvec_t *aubio_batchnorm_get_beta(aubio_batchnorm_t *t); 89 90 /** get a pointer to the moving mean vector 91 92 \param t ::aubio_batchnorm_t layer 93 94 \return pointer to `fvec_t` holding the moving mean parameters 95 96 */ 97 fvec_t *aubio_batchnorm_get_moving_mean(aubio_batchnorm_t *t); 98 99 /** get a pointer to the moving variance vector 100 101 \param t ::aubio_batchnorm_t layer 102 103 \return pointer to `fvec_t` holding the moving variance parameters 104 105 */ 106 fvec_t *aubio_batchnorm_get_moving_variance(aubio_batchnorm_t *t); 107 108 /** set gamma vector of batchnorm layer 109 110 \param t ::aubio_batchnorm_t layer 111 \param gamma ::fvec_t containing the weights 112 113 \return 0 on success, non-zero otherwise. 114 115 This function will copy the content of an existing vector into 116 the corresponding vector of weights in `t`. 117 118 Note: to spare a copy and load directly the data in `t`, 119 ::aubio_batchnorm_get_gamma can be used instead. 120 121 */ 122 uint_t aubio_batchnorm_set_gamma(aubio_batchnorm_t *t, fvec_t *gamma); 123 124 /** set beta vector of a batchnorm layer 125 126 \param t ::aubio_batchnorm_t layer 127 \param beta ::fvec_t containing the weights 128 129 \return 0 on success, non-zero otherwise. 130 131 */ 132 uint_t aubio_batchnorm_set_beta(aubio_batchnorm_t *t, fvec_t *beta); 133 134 /** set moving mean vector of batchnorm layer 135 136 \param t ::aubio_batchnorm_t layer 137 \param moving_mean ::fvec_t containing the weights 138 139 \return 0 on success, non-zero otherwise. 140 141 */ 142 uint_t aubio_batchnorm_set_moving_mean(aubio_batchnorm_t *t, 143 fvec_t *moving_mean); 144 145 /** set moving variance vector of batchnorm layer 146 147 \param t ::aubio_batchnorm_t layer 148 \param moving_variance ::fvec_t containing the weights 149 150 \return 0 on success, non-zero otherwise. 151 152 */ 153 uint_t aubio_batchnorm_set_moving_variance(aubio_batchnorm_t *t, 154 fvec_t *moving_variance); 155 156 /** compute batch normalization layer 157 158 \param t ::aubio_batchnorm_t layer 159 \param input_tensor input tensor 160 \param activations output tensor 161 162 \return 0 on success, non-zero otherwise. 163 164 */ 165 void aubio_batchnorm_do(aubio_batchnorm_t *t, aubio_tensor_t *input_tensor, 166 aubio_tensor_t *activations); 167 168 /** delete batch normalization layer 169 170 \param t ::aubio_batchnorm_t layer to delete 171 172 */ 62 173 void del_aubio_batchnorm(aubio_batchnorm_t *t); 63 174
Note: See TracChangeset
for help on using the changeset viewer.