Changeset 7f915f7


Ignore:
Timestamp:
Dec 29, 2021, 5:52:01 PM (3 weeks ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe
Children:
ecb9f64
Parents:
11e6f7a
git-author:
Paul Brossier <piem@piem.org> (01/29/19 03:03:51)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:52:01)
Message:

[conv1d] add basic documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ai/conv1d.h

    r11e6f7a r7f915f7  
    2222#define AUBIO_CONV1D_H
    2323
     24/** \file
     25
     26  Convolutional layer (1D)
     27
     28  Standard implementation of a 1D convolutional layer, partly optimized for
     29  CPU.
     30
     31  Note
     32  ----
     33  Only the forward pass is implemented for now.
     34
     35  References
     36  ----------
     37  Vincent Dumoulin, Francesco Visin - A guide to convolution arithmetic for
     38  deep learning. https://github.com/vdumoulin/conv_arithmetic
     39
     40*/
     41
    2442#ifdef __cplusplus
    2543extern "C" {
    2644#endif
    2745
     46/** conv1d layer */
    2847typedef struct _aubio_conv1d_t aubio_conv1d_t;
    2948
    30 /** create a new conv1d layer */
    31 aubio_conv1d_t *new_aubio_conv1d(uint_t filters, uint_t kernel_shape[1]);
     49/** create a new conv1d layer
    3250
    33 /** perform forward 1D convolution */
    34 void aubio_conv1d_do(aubio_conv1d_t *t, aubio_tensor_t *input_tensor,
    35         aubio_tensor_t *activations);
     51  \param n_filters number of filters
     52  \param kernel_shape length of each filter
    3653
    37 /** TODO: implement */
    38 void aubio_conv1d_train(aubio_conv1d_t *t, aubio_tensor_t *input_tensor);
     54  \return new conv1d layer
    3955
    40 /** get conv1d weights */
    41 aubio_tensor_t *aubio_conv1d_get_kernel(aubio_conv1d_t *t);
     56*/
     57aubio_conv1d_t *new_aubio_conv1d(uint_t n_filters, uint_t kernel_shape[1]);
    4258
    43 /** get conv1d biases */
    44 fvec_t *aubio_conv1d_get_bias(aubio_conv1d_t *t);
     59/** set padding mode
    4560
    46 /** set conv1d stride */
    47 uint_t aubio_conv1d_set_stride(aubio_conv1d_t *c, uint_t stride[1]);
     61  \param c                  layer
     62  \param padding_mode       padding mode
    4863
     64  \return 0 on success, non-zero otherwise
     65
     66  Available padding: "same", and "valid".
     67
     68  Todo:
     69  - add causal mode
     70
     71*/
    4972uint_t aubio_conv1d_set_padding_mode(aubio_conv1d_t *c,
    5073    const char_t *padding_mode);
    5174
     75/** set stride
     76
     77  \param c      layer
     78  \param stride array of length 1 containing the stride parameter
     79
     80  \return 0 on success, non-zero otherwise
     81
     82*/
     83uint_t aubio_conv1d_set_stride(aubio_conv1d_t *c, uint_t stride[1]);
     84
     85/** get current stride settings
     86
     87  \param t  layer
     88
     89  \return   array of length 1 containing the stride parameter
     90
     91*/
     92uint_t *aubio_conv1d_get_stride(aubio_conv1d_t* t);
     93
     94/** get output shape
     95
     96  \param t                  layer
     97  \param input_tensor       input tensor
     98  \param shape              output shape
     99
     100  \return 0 on success, non-zero otherwise
     101
     102  Upon return, `shape` will be filled with the output shape of the layer. This
     103  function should be called after ::aubio_conv1d_set_stride or
     104  ::aubio_conv1d_set_padding_mode, and before ::aubio_conv1d_get_kernel or
     105  ::aubio_conv1d_get_bias.
     106
     107*/
    52108uint_t aubio_conv1d_get_output_shape(aubio_conv1d_t *t,
    53109        aubio_tensor_t *input_tensor, uint_t *shape);
    54110
     111/** get kernel weights
     112
     113  \param t ::aubio_conv1d_t layer
     114
     115  \return tensor of weights
     116
     117  When called after ::aubio_conv1d_get_output_shape, this function will return
     118  a pointer to the tensor holding the weights of this layer.
     119
     120*/
     121aubio_tensor_t *aubio_conv1d_get_kernel(aubio_conv1d_t *t);
     122
     123/** get biases
     124
     125  \param t layer
     126
     127  \return vector of biases
     128
     129  When called after ::aubio_conv1d_get_output_shape, this function will return
     130  a pointer to the vector holding the biases.
     131
     132*/
     133fvec_t *aubio_conv1d_get_bias(aubio_conv1d_t *t);
     134
     135/** set kernel weights
     136
     137  \param t          layer
     138  \param kernel     kernel weights
     139
     140  \return 0 on success, non-zero otherwise
     141
     142  Copy kernel weights into internal layer memory.  This function should be
     143  called after ::aubio_conv1d_get_output_shape.
     144
     145*/
     146uint_t aubio_conv1d_set_kernel(aubio_conv1d_t *t, aubio_tensor_t *kernel);
     147
     148/** set biases
     149
     150  \param t          layer
     151  \param bias       biases
     152
     153  \return 0 on success, non-zero otherwise
     154
     155  Copy vector of biases into internal layer memory. This function should be
     156  called after ::aubio_conv1d_get_output_shape.
     157
     158*/
     159uint_t aubio_conv1d_set_bias(aubio_conv1d_t *t, fvec_t *bias);
     160
     161/** compute layer output
     162
     163  \param t              layer
     164  \param input_tensor   input tensor
     165  \param output_tensor  output tensor
     166
     167  Perform 1D convolution.
     168
     169*/
     170void aubio_conv1d_do(aubio_conv1d_t *t, aubio_tensor_t *input_tensor,
     171        aubio_tensor_t *output_tensor);
     172
     173/** destroy conv1d layer
     174
     175  \param t  layer
     176
     177*/
    55178void del_aubio_conv1d(aubio_conv1d_t *t);
    56179
Note: See TracChangeset for help on using the changeset viewer.