Skip to content

Instantly share code, notes, and snippets.

View zommiommy's full-sized avatar
💤
Too tired to live

Tommaso Fontana zommiommy

💤
Too tired to live
View GitHub Profile
@zommiommy
zommiommy / main.py
Last active May 31, 2022 14:20
Manual Logistic Regression with SGD, Momentum, Adam, Nadam
import time
import numpy as np
from tqdm.auto import trange
import matplotlib.pyplot as plt
from optimizers import SGD, Momentum, Adam, Nadam
# Generate some data
positives = np.random.normal(loc=-0.3, size=1000)
negatives = np.random.normal(loc=0.0, size=1000)
@zommiommy
zommiommy / bench.rs
Last active January 23, 2022 10:29
Benching of AVX dish vs relu
#![feature(portable_simd)]
#![feature(test)]
extern crate test;
use test::{black_box, Bencher};
use std::convert::TryInto;
use std::simd::*;
use std::arch::x86_64::*;
type Reg = f32x8;
@zommiommy
zommiommy / Cargo.toml
Last active October 8, 2021 10:46
Benchmark template
[package]
name = "bencher"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2"
@zommiommy
zommiommy / results.txt
Last active July 27, 2021 20:46
Benchmarks of different split implementations in rust.
test bench_naive_split ... bench: 2,265,338 ns/iter (+/- 136,512)
test bench_naive_split_no_escaping ... bench: 2,287,644 ns/iter (+/- 309,993)
test bench_naive_split_no_escaping_hardcoded ... bench: 2,650,552 ns/iter (+/- 27,290)
test bench_rust_default_split ... bench: 4,118,575 ns/iter (+/- 153,705)
test bench_simd_split_no_escaping ... bench: 1,707,197 ns/iter (+/- 83,440)
test bench_simd_split_no_escaping_hardcoded ... bench: 1,688,714 ns/iter (+/- 11,317)
@zommiommy
zommiommy / Makefile
Last active May 19, 2021 19:38
Experiments on the consistency of rdtsc and rdtscp
build:
nasm -f elf64 -o measure.o ./measure.asm
ld measure.o -o measure.out -lc --dynamic-linker /lib/ld-2.33.so
@zommiommy
zommiommy / writeup.md
Last active May 17, 2021 17:57
M0lecon Writeup

M0lecon RE Writeup

TLDR

  • Reverse the code
  • Re-implment it in Rust
  • Bruteforce
  • ???
  • Profit

Automatic Rejection Machine

@zommiommy
zommiommy / embracenet.py
Last active March 25, 2021 10:29
Implementation of EmbraceLayer, this requires eagerly execution, for now.
from tensorflow.keras.layers import Input, Dense, Layer, Lambda
from tensorflow.keras.models import Model
import tensorflow.keras.backend as K
def setup_embrace_layer(modalities=2, num_samples=256):
def embrace(dockings):
batch_size = K.shape(dockings[0])[0]
# Compute the probabilities of extraction
selection_probabilities = tf.ones([batch_size, len(dockings)], dtype=tf.dtypes.float32)
probabilty_sum = tf.reduce_sum(selection_probabilities, axis=-1, keepdims=True) # [batch_size, 1]
@zommiommy
zommiommy / x.py
Last active December 2, 2020 21:33
HITCON2020 dual expolit
from pwn import *
libc = ELF('/lib/x86_64-linux-gnu/libc-2.31.so')
host = '13.231.226.137'
port = 9573
p = remote(host, port)
def op():
@zommiommy
zommiommy / keras_metrics.py
Last active November 10, 2020 12:35
A bunch of metrics for binary classification tasks implemented in Keras
import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras.metrics import Metric, AUC
from tensorflow.keras.backend import epsilon
class ConfusionMatrixMetric(Metric):
def __init__(self, name, **kwargs):
super(ConfusionMatrixMetric, self).__init__(name=name, **kwargs)
self.tp = self.add_weight(name='tp', initializer='zeros')
self.fp = self.add_weight(name='fp', initializer='zeros')
@zommiommy
zommiommy / tldr.md
Created August 4, 2020 06:31
Tensorflow gpu setup for ubuntu

How to setup tensorflow gor gpu on Ubuntu

To check if tensorflow can detect any GPU just run

python -c "import tensorflow as tf;print(tf.test.is_gpu_available(True))"

If the GPUs are available it should print True.

Setup anaconda

The easiest way to setup cuda and tensorflow-gpu is to install everything using anaconda. Anaconda do not requires root permissions and create a self-contained folder in $HOME/anaconda3.