Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file owl_algodiff_generic_sig.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511# 1 "src/base/optimise/owl_algodiff_generic_sig.ml"(*
* OWL - OCaml Scientific and Engineering Computing
* Copyright (c) 2016-2018 Liang Wang <liang.wang@cl.cam.ac.uk>
*)openOwl_typesmoduletypeSig=sigmoduleA:Owl_types_ndarray_algodiff.Sig(** {6 Type definition} *)typetrace_op(** Trace type *)typet=|FofA.elt(* constructor of float numbers *)|ArrofA.arr(* constructor of ndarrays *)|DFoft*t*int(* primal, tangent, tag *)|DRoft*tref*trace_op*intref*int(* primal, adjoint, op, fanout, tag *)(** Abstract number type *)(** {6 Supported Maths functions} *)moduleMaths:sigval(+):t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)val(-):t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)val(*):t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)val(/):t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)val(*@):t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)val(**):t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valadd:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsub:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmul:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valdiv:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valdot:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valpow:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valatan2:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmin2:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmax2:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valcross_entropy:t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valinv:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valneg:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valabs:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsignum:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valfloor:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valceil:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valround:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsqr:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsqrt:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)vallog:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)vallog2:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)vallog10:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valexp:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsin:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valcos:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valtan:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsinh:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valcosh:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valtanh:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valasin:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valacos:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valatan:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valasinh:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valacosh:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valatanh:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsum':t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsum:?axis:int->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsum_reduce:?axis:intarray->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmean:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valtranspose:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)vall1norm':t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)vall2norm':t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)vall2norm_sqr':t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsigmoid:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valrelu:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsoftplus:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsoftsign:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valsoftmax:?axis:int->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valdropout:?rate:float->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valconv1d:?padding:padding->t->t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valconv2d:?padding:padding->t->t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valconv3d:?padding:padding->t->t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valdilated_conv1d:?padding:padding->t->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valdilated_conv2d:?padding:padding->t->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valdilated_conv3d:?padding:padding->t->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valtranspose_conv1d:?padding:padding->t->t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valtranspose_conv2d:?padding:padding->t->t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valtranspose_conv3d:?padding:padding->t->t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmax_pool1d:padding->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmax_pool2d:padding->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valmax_pool3d:padding->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valavg_pool1d:padding->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valavg_pool2d:padding->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valavg_pool3d:padding->t->intarray->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valreshape:t->intarray->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valflatten:t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valconcat:int->t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valget_slice:intlistlist->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)valset_slice:intlistlist->t->t->t(** Refer to :doc:`owl_dense_ndarray_generic` *)end(* Simple wrappers of matrix and ndarray module, so you don't have to pack
and unpack stuff all the time. Some operations just interface to those
already defined in the Maths module. *)moduleMat:sigvalempty:int->int->tvalzeros:int->int->tvalones:int->int->tvaluniform:?a:A.elt->?b:A.elt->int->int->tvalgaussian:?mu:A.elt->?sigma:A.elt->int->int->tvalshape:t->int*intvalnumel:t->intvalrow_num:t->intvalcol_num:t->intvalreset:t->unitvalreshape:int->int->t->tvalget:t->int->int->tvalset:t->int->int->t->tvalrow:t->int->tvaladd:t->t->tvalsub:t->t->tvalmul:t->t->tvaldiv:t->t->tvaldot:t->t->tvalmap_by_row:(t->t)->t->tvalof_arrays:A.eltarrayarray->tvalprint:t->unitendmoduleArr:sigvalempty:intarray->tvalzeros:intarray->tvalones:intarray->tvaluniform:?a:A.elt->?b:A.elt->intarray->tvalgaussian:?mu:A.elt->?sigma:A.elt->intarray->tvalshape:t->intarrayvalnumel:t->intvalreset:t->unitvalreshape:t->intarray->tvaladd:t->t->tvalsub:t->t->tvalmul:t->t->tvaldiv:t->t->tend(** {6 Core functions} *)valdiff:(t->t)->t->t(**
``diff f x`` returns the exat derivative of a function ``f : scalar -> scalar``
at point ``x``. Simply calling ``diff f`` will return its derivative function ``g``
of the same type, i.e. ``g : scalar -> scalar``.
Keep calling this function will give you higher-order derivatives of ``f``, i.e.
``f |> diff |> diff |> diff |> ...``
*)valdiff':(t->t)->t->t*t(** similar to ``diff``, but return ``(f x, diff f x)``. *)valgrad:(t->t)->t->t(** gradient of ``f`` : (vector -> scalar) at ``x``, reverse ad. *)valgrad':(t->t)->t->t*t(** similar to ``grad``, but return ``(f x, grad f x)``. *)valjacobian:(t->t)->t->t(** jacobian of ``f`` : (vector -> vector) at ``x``, both ``x`` and ``y`` are row vectors. *)valjacobian':(t->t)->t->t*t(** similar to ``jacobian``, but return ``(f x, jacobian f x)`` *)valjacobianv:(t->t)->t->t->t(**
jacobian vector product of ``f`` : (vector -> vector) at ``x`` along ``v``,
forward ad. Namely, it calcultes ``(jacobian x) v``
*)valjacobianv':(t->t)->t->t->t*t(** similar to ``jacobianv'``, but return ``(f x, jacobianv f x v)`` *)valjacobianTv:(t->t)->t->t->t(**
transposed jacobian vector product of ``f : (vector -> vector)`` at ``x``
along ``v``, backward ad. Namely, it calculates ``transpose ((jacobianv f x v))``.
*)valjacobianTv':(t->t)->t->t->t*t(** similar to ``jacobianTv``, but return ``(f x, transpose (jacobianv f x v))`` *)valhessian:(t->t)->t->t(** hessian of ``f`` : (scalar -> scalar) at ``x``. *)valhessian':(t->t)->t->t*t(** simiarl to ``hessian``, but return ``(f x, hessian f x)`` *)valhessianv:(t->t)->t->t->t(**
hessian vector product of ``f`` : (scalar -> scalar) at ``x`` along ``v``.
Namely, it calculates ``(hessian x) v``.
*)valhessianv':(t->t)->t->t->t*t(** similar to ``hessianv``, but return ``(f x, hessianv f x v)``. *)vallaplacian:(t->t)->t->t(** laplacian of ``f : (scalar -> scalar)`` at ``x``. *)vallaplacian':(t->t)->t->t*t(** simiar to ``laplacian``, but return ``(f x, laplacian f x)``. *)valgradhessian:(t->t)->t->t*t(** return ``(grad f x, hessian f x)``, ``f : (scalar -> scalar)`` *)valgradhessian':(t->t)->t->t*t*t(** return ``(f x, grad f x, hessian f x)`` *)valgradhessianv:(t->t)->t->t->t*t(** return ``(grad f x v, hessian f x v)`` *)valgradhessianv':(t->t)->t->t->t*t*t(** return ``(f x, grad f x v, hessian f x v)`` *)(** {6 Low-level functions} *)(* low-level functions, only use them if you know what you are doing. *)valpack_elt:A.elt->t(** convert from ``elt`` type to ``t`` type. *)valunpack_elt:t->A.elt(** convert from ``t`` type to ``elt`` type. *)valpack_flt:float->t(** convert from ``float`` type to ``t`` type. *)valunpack_flt:t->float(** convert from ``t`` type to ``float`` type. *)valpack_arr:A.arr->t(** convert from ``arr`` type to ``t`` type. *)valunpack_arr:t->A.arr(** convert from ``t`` type to ``arr`` type. *)valtag:unit->int(** TODO *)valprimal:t->t(** TODO *)valprimal':t->t(** TODO *)valadjval:t->t(** TODO *)valadjref:t->tref(** TODO *)valtangent:t->t(** TODO *)valmake_forward:t->t->int->t(** TODO *)valmake_reverse:t->int->t(** TODO *)valreverse_prop:t->t->unit(** TODO *)valtype_info:t->string(** TODO *)valshape:t->intarray(** TODO *)valcopy_primal':t->t(** TODO *)val_f:float->t(** A shortcut function for ``F A.(float_to_elt x)``. *)valclip_by_value:amin:A.elt->amax:A.elt->t->t(** other functions, without tracking gradient *)valclip_by_l2norm:A.elt->t->t(** other functions, without tracking gradient *)(** {6 Helper functions} *)valto_trace:tlist->string(**
``to_trace [t0; t1; ...]`` outputs the trace of computation graph on the
terminal in a human-readable format.
*)valto_dot:tlist->string(**
``to_dot [t0; t1; ...]`` outputs the trace of computation graph in the dot
file format which you can use other tools further visualisation, such as
Graphviz.
*)valpp_num:Format.formatter->t->unit(** ``pp_num t`` pretty prints the abstract number used in ``Algodiff``. *)end