Skip to content

Instantly share code, notes, and snippets.

View aletheia's full-sized avatar
🏠
Working from home

Luca Bianchi aletheia

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am aletheia on github.
  • I am aletheia1982 (https://keybase.io/aletheia1982) on keybase.
  • I have a public key ASDD8nTTwlydf9VE8FzkqvXEMnJa5rNtaie-qMq-FqLhLQo

To claim this, I am signing this object:

data:
{
"message":{
"id":"a49b7544-f0eb-43eb-9e56-f28b2961bf19",
"role":"assistant",
"user":null,
"create_time":null,
"update_time":null,
"content":{
"content_type":"text",
data:
{
"message": {
"id": "a49b7544-f0eb-43eb-9e56-f28b2961bf19",
"role": "assistant",
"user": null,
"create_time": null,
"update_time": null,
"content": {
"content_type": "text",
{
"user": {
"id": "user-myuserid",
"name": "Luca Bianchi",
"email": "luca.bianchi@myemail.com",
"image": "https://path/to/user/image",
"picture": "https://path/to/profile/picture",
"groups": [
"codex",
"sunset-search-endpoint",
{
"action": "variant",
"messages": [
{
"id": "b866650c-4797-4fc9-91dc-962af79ff369",
"role": "user",
"content": {
"content_type": "text",
"parts": [
"Who are you?"
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
AWS Lambda Rust ML -- Example showing how to use Rust with AWS Lambda to build a customer churn predictor
Globals:
Function:
Resources:
S3ModelBucket:
#[derive(Deserialize, Serialize)]
struct User {
customer_id: String,
senior_citizen: i32,
#[serde(default, rename = "churnProbability")]
churn_probability: Option<f64>,
#[serde(rename = "MonthlyCharges")]
monthly_charges: f64,
#[serde(rename = "TotalCharges")]
total_charges: f64,
@aletheia
aletheia / UserRustTraits.rs
Last active September 7, 2022 20:19
a trait to cast User into Vec
impl From<&User> for Vec<f64> {
fn from(user: &User) -> Vec<f64> {
vec![
user.senior_citizen as f64,
user.tenure as f64,
user.monthly_charges,
user.total_charges,
// ... more fields are omitted for brevity
]
}
def validation_step(self, batch, batch_idx):
''' Prforms model validation computing cross entropy for predictions and labels
'''
x, labels = batch
prediction = self.forward(x)
return {
'val_loss': F.cross_entropy(prediction, labels)
}
def validation_epoch_end(self, outputs):
def training_step(self, batch, batch_idx):
'''Called for every training step, uses NLL Loss to compute training loss, then logs and sends back
logs parameter to Trainer to perform backpropagation
'''
# Get input and output from batch
x, labels = batch
# Compute prediction through the network
prediction = self.forward(x)