This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let _some_obj = self.some_obj.clone(); | |
tokio::task::spawn(async move { | |
process(_some_obj) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone)] | |
struct SomethingBig { | |
name: String, | |
children: Vec<SomethingBig>, | |
} | |
impl SomethingBig { | |
fn modify(&mut self) { | |
self.name = "modified".to_string(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result: Result<f64, String> = divide_function(100.23, 73.98); | |
match result { | |
Ok(x) => println!("Result: {}", x), | |
Err(e) => println!("Error: {}", e), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result: Option<String> = Some("hello".to_string); | |
match result { | |
Some(x) => println!("Result: {}", x), | |
None => println!("Error"), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Epoch | Training Loss | Validation Loss | Accuracy | F1 | | |
|-------|---------------|-----------------|----------|----------| | |
| 1 | No log | 0.383960 | 0.830882 | 0.883249 | | |
| 2 | 0.507400 | 0.558366 | 0.845588 | 0.891192 | | |
| 3 | 0.259800 | 0.712663 | 0.865196 | 0.905009 | | |
TrainOutput(global_step=1377, training_loss=0.3134817651154429, metrics={'train_runtime': 241.2671, 'train_samples_per_second': 45.609, 'train_steps_per_second': 5.707, 'total_flos': 405114969714960.0, 'train_loss': 0.3134817651154429, 'epoch': 3.0}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from transformers import TrainingArguments | |
from transformers import Trainer | |
import evaluate | |
metric = evaluate.load("glue", "mrpc") | |
def compute_metrics(eval_preds): | |
logits, labels = eval_preds | |
predictions = np.argmax(logits, axis=-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stateDiagram-v2 | |
Metrics --> Trainer | |
Hyperparameters --> Trainer | |
Model --> Trainer | |
Metrics --> Trainer | |
TrainingDataset --> Trainer | |
ValidationDataset --> Trainer | |
TestDataset --> Trainer | |
Tokenizer --> Trainer | |
DataCollator --> Trainer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Epoch 1/3 | |
Training Loss: 0.5249 | |
Validation Loss: 0.4029 | |
Evaluation Metrics: {'accuracy': 0.8284313725490197, 'f1': 0.8741007194244604} | |
Epoch 2/3 | |
Training Loss: 0.2626 | |
Validation Loss: 0.3794 | |
Evaluation Metrics: {'accuracy': 0.8529411764705882, 'f1': 0.8979591836734694} | |
Epoch 3/3 | |
Training Loss: 0.0937 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import AutoModelForSequenceClassification | |
import torch | |
from transformers import AdamW | |
from transformers import get_scheduler | |
from tqdm.auto import tqdm | |
import evaluate | |
# Initialize metric and model | |
metric = evaluate.load("glue", "mrpc") | |
model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
torch.Size([16, 80]) | |
torch.Size([16, 72]) | |
torch.Size([16, 84]) | |
torch.Size([16, 86]) | |
torch.Size([16, 75]) |
NewerOlder