Create and activate an environment
conda create -n python2 python=2.7 anaconda
source activate python2
Deactivate environment
import re | |
import fitz | |
from fitz import Page | |
import argparse | |
import pandas as pd | |
from pathlib import Path | |
from collections import defaultdict | |
EXCLUDE_KEYWORD = [ |
import pandas as pd | |
from pathlib import Path | |
from functools import wraps | |
def cache_pandas_result(cache_dir, hard_reset: bool): | |
''' | |
This decorator caches a pandas.DataFrame returning function. | |
It saves the pandas.DataFrame in a parquet file in the cache_dir. | |
It uses the following naming scheme for the caching files: |
model.zero_grad() # Reset gradients tensors | |
for i, (inputs, labels) in enumerate(training_set): | |
predictions = model(inputs) # Forward pass | |
loss = loss_function(predictions, labels) # Compute loss function | |
loss = loss / accumulation_steps # Normalize our loss (if averaged) | |
loss.backward() # Backward pass | |
if (i+1) % accumulation_steps == 0: # Wait for several backward steps | |
optimizer.step() # Now we can do an optimizer step | |
model.zero_grad() # Reset gradients tensors | |
if (i+1) % evaluation_steps == 0: # Evaluate the model when we... |
- Reset current branch to the parent of HEAD | |
git reset --soft HEAD~ | |
- Reset the unwanted files in order to leave them out from the commit: | |
git reset HEAD path/to/unwanted_file | |
- Commit again using the same commit message: | |
git commit -c ORIG_HEAD | |
(*) git reset --soft HEAD~ |