Skip to content

Instantly share code, notes, and snippets.

View esshka's full-sized avatar
🏠
Working from home

Eugeny esshka

🏠
Working from home
View GitHub Profile
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
public class UnsafeNN implements NN {
private final double[] z1;
private final double[] z2;
private final ByteBuffer bb;
private final DoubleBuffer db;
private final double[] o;
@esshka
esshka / rehuy.js
Created July 11, 2024 19:25
rehuy
const ctx = [];
function addEffect(current, effects) {
effects.add(current);
current.deps.add(effects);
}
function createAtom(value) {
const effects = new Set();
(import 'java.lang.management.ManagementFactory)
(import 'com.sun.management.HotSpotDiagnosticMXBean)
(let [server (ManagementFactory/getPlatformMBeanServer)
bean-name "com.sun.management:type=HotSpotDiagnostic"
bean (ManagementFactory/newPlatformMXBeanProxy server bean-name HotSpotDiagnosticMXBean)
live-objects-only? false]
(.dumpHeap bean "dump.hprof" live-objects-only?))
@esshka
esshka / min-char-rnn.py
Created June 21, 2024 13:34 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
(ns datastructures.queue
(:refer-clojure :exclude [compare-and-set! pop])
(:import java.util.concurrent.atomic.AtomicReference))
(defn- compare-and-set! [^AtomicReference aref oldval newval]
(or (.compareAndSet aref oldval newval)
(throw (RuntimeException. ::loop))))
(defmacro with-contention
[& body]
@esshka
esshka / async_util.clj
Created March 1, 2024 23:46 — forked from echeran/async_util.clj
Utility functions for core.async 0.1.346.0-17112a-alpha to create a linear pipeline of go-routines in a Storm-esque way.
(ns your.namespace.async-util
(:require
[clojure.core.async :as a :refer [>! <! >!! <!! go chan buffer
close! thread alts! alts!! timeout]]
[clojure.core.match :as match :refer [match]]))
;;
;; core.async util fns
;;
@esshka
esshka / tensorflow-gpu-in-jupyter-lab.md
Created February 12, 2024 16:38 — forked from anirban94chakraborty/tensorflow-gpu-in-jupyter-lab.md
Install Tensorflow-GPU (for NVIDIA GPUs) for use in JupyterLab using Anaconda

Install Tensorflow-GPU (for NVIDIA GPUs) for use in JupyterLab using Anaconda

This tutorial is for computers with NVIDIA GPUs installed.

Tensorflow for GPU significantly reduces the time taken by Deep Neural Networks (like CNNs, LSTMs, etc) to complete each Epoch (compute cycle) by utilizing the CUDA cores present in the GPU for parallel processing.

The following steps are to be followed:

  1. Make sure that you have installed the latest drivers of your NVIDIA GPU for your OS.
@esshka
esshka / polebench.js
Created February 9, 2024 16:13
pole balancing benchmark for genetic algorithm
const MAX_TIMESTEPS = 1000;
function initializeCartPoleEnvironment() {
const gravity = 9.8; // Acceleration due to gravity, m/s^2
const cartMass = 1.0; // Mass of the cart
const poleMass = 0.1; // Mass of the pole
const totalMass = cartMass + poleMass;
const length = 0.5; // Half the pole's length
const poleMassLength = poleMass * length;
const forceMagnitude = 10.0; // Magnitude of the force applied to the cart
@esshka
esshka / understanding-word-vectors.ipynb
Created January 25, 2024 01:12 — forked from aparrish/understanding-word-vectors.ipynb
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@esshka
esshka / createFitnessFunction.js
Created October 26, 2023 17:49
base fitness function for NEAT
const createFitnessFunction = (dataset, { repeat = 1, cost }) => {
return network => {
let score = 0
for (let i = 0; i < repeat; i++) {
const result = network.test(dataset, cost)
if (!result || typeof result.error === 'undefined') {
throw new Error('The test method did not return a valid result with an error property.')
}