Skip to content

Q: What types can be used with autodiff? #454

@srush

Description

@srush

I'm curious what type of functions one should be able grad over. i.e. what is the implicit restriction on a

def grad (f:a->Float) (x:a) : a = snd (vjp f x) 1.0

Currently it seems to work for tables and tuples, but other things crash for me (for instance custom data types).

Was playing around with something Flax-like for grouping params and functions, but I think this might be the wrong path given #331 and because I am not smart enough to figure out how to unpack a tuple a Params to a Param of a tuples.

data Param a =                                                                                            
  AsParam a                                                                                            
  Init ParamInit 

def Layer (inp:Type) (out:Type) (param:Type) : Type=                                                      
  {forward:({key: Key & params:param} -> inp -> out) &                                                    
   params: param &                                                                                        
   init: Bool }   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions