Skip to content

Instantly share code, notes, and snippets.

View ZaydH's full-sized avatar

Zayd Hammoudeh ZaydH

View GitHub Profile
import sys
import pickle
from pathlib import Path
import torch
import numpy as np
from tqdm import tqdm
DATA_DIR = Path("data")
@ZaydH
ZaydH / sleipnir_merge_dataset.py
Created August 12, 2019 11:33
Script for Merging all SLEIPNIR Feature Vectors
import sys
import pickle
from pathlib import Path
import torch
import numpy as np
from tqdm import tqdm
DATA_DIR = Path("data")
@ZaydH
ZaydH / skorch_issue_batch_size_1.py
Created May 18, 2019 03:43
Skorch Bug - Batch Size 1
import torch
import torch.nn as nn
from skorch import NeuralNetClassifier
num_classes = 5
input_width = 10
class Module(nn.Module):
@ZaydH
ZaydH / README_CPLEX_Max-Flow_Min-Cut.md.md
Last active April 20, 2022 14:31
Python CPLEX: Max Flow/Min Cut

Max Flow/Min Cut Using CPLEX in Python

This program uses the Python cplex library to solve a max flow/min cut problem. More information on max flow/min cut is available in the Wikipedia article.
The basic idea is to assign flow to each edge such that no edge's flow exceeds that edge's capacity.

Be aware that a linear program may not always be the most efficient technique for solving max flow/min cut. This gist is intended more as a demonstration of how to use CPLEX in Python.

The graph I used is:

@ZaydH
ZaydH / README_CPLEX_Vertex_Cover.md
Last active January 14, 2024 13:59
Python CPLEX: Minimum Vertex Cover

Vertex Cover Using CPLEX in Python

This program uses the Python cplex library to solve a vertex cover problem. More information on Vertex Cover is available in the Wikipedia article. The basic idea of the problem is to select the smallest set of vertices such that each edge in the graph is incident on at least one selected vertex. Solving vertex cover is NP-Hard.

For this example, I used the toy graph below.

g