Skip to content

Instantly share code, notes, and snippets.

View mahyarmirrashed's full-sized avatar
🎋
Hopeful and happy

Mahyar Mirrashed mahyarmirrashed

🎋
Hopeful and happy
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
// Sigmoid activation function
double sigmoid(double x) {
return 1.0 / (1.0 + exp(-x));
}
@mahyarmirrashed
mahyarmirrashed / dict_mixin.py
Last active June 22, 2023 19:10
Python Dataclass Dictionary Mixin
from dataclasses import asdict as _to_dict, fields, is_dataclass
from typing import Any, Dict, Mapping, Type, TypeVar
T = TypeVar("T", bound="DictMixin")
U = TypeVar("U")
def _from_dict(cls: Type[U], src: Mapping[str, Any]) -> U:
field_types_lookup = {field.name: field.type for field in fields(cls)}