Function serve_model

  • Serve a model with forward and optimization endpoints.


    This server is to be used with network.remote_model. The function does not return.


    const weight = sm.randn([128, 128]).requireGrad()
    function model(input) {
    return input.matmul(weight).maximum(sm.scalar(0))

    function optimize(differentiated_tensors) {
    for (let t of differentiated_tensors) {
    }, optimize)

    Additional functions can also be served (as in network.serve):

    function extraMethod() {
    return sm.identity(7)
    }, sm.optim.sgd, {port:3000}, {
    ident: extraMethod


    • fn: ((t: Tensor) => Tensor | Promise<Tensor>)

      A function that will run on forward calls

    • grad_update: OptimizerFn

      A function that will run on backward calls, with a list of differentiated tensors passed in

    • options: ServeOptions

      An optional list of options passed to the underlying Bun.serve call

    • Optional req_map: Record<string, ((...args: unknown[]) => unknown)>

      An optional map of additional handlers passed to the underlying network.serve call

    Returns void

Generated using TypeDoc