Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Create a set of integrated procedural macros for building differentiable functions, methods, etc. #77

@FL03

Description

@FL03

Example

extern crate acme;

use acme::{autodiff, operator};

fn main() {
    let x = 5f64;
    let (z, dz) = (sigmoid(x), sigmoid_prime(x));
    assert_eq!(autodiff!(lex x: sigmoid_lexical()), dz);
}

#[operator(partial)]
pub fn sigmoid<T>(x: T) -> T where T: num::Float {
    x.exp() / (T::one() + x.exp())
}

pub fn sigmoid_prime<T>(x: T) -> T where T: num::Float {
    sigmoid(x) * (1 - sigmoid(x)
}

Try to integrate with the #[operator] macro by collecting the String created by invoking _lexical()

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestmacroAny additions or improvements to procedural macrosrustImprovements or additions that update the Rust code

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions