Skip to content

Instantly share code, notes, and snippets.

@atksh
atksh / onnx_optimize.py
Created March 19, 2022 23:43
onnx optimization w/ quantize
import os
import shutil
import tempfile
import onnx
import onnxruntime as rt
from onnxruntime.quantization import QuantType, quantize_dynamic
def opt_by_rt(input_model: str, output_model: str):
@atksh
atksh / IEEE-111073-16bit-sfloat-to-float.py
Created June 29, 2021 12:50
convert IEEE-111073-16bit-sfloat to float
import numpy as np
def to_float_from_11073_16bit_sfloat(data):
tmp = int.from_bytes(data, "little")
uint16val = np.array([tmp], dtype=np.uint16)
tmp = bin(uint16val[0] & 0xfff)
mantissa = int(tmp, 0)
@atksh
atksh / wbic_pymc3.py
Last active August 9, 2022 20:12
Estimating the mixed normal distribution in PyMC3. Model selection with WBIC using normal and mixed normal distributions.
import warnings
warnings.filterwarnings('ignore')
import pymc3 as pm
from pymc3.distributions.dist_math import bound
import theano.tensor as tt
import theano
import numpy as np
np.random.seed(seed=32)