Skip to content

Instantly share code, notes, and snippets.

View andrewschreiber's full-sized avatar
🎯
Focusing

Andrew Schreiber andrewschreiber

🎯
Focusing
View GitHub Profile
import torch
import numpy as np
import pickle
f = open('/home/eriba/software/pytorch/examples-edgarriba/triplet/nan_test.pkl', 'rb')
data = pickle.load(f)
a = torch.from_numpy(data['a']).cuda()
@tokestermw
tokestermw / restore_tf_models.py
Created February 21, 2017 21:09
Restoring frozen models are hard in TensorFlow.
"""
Play with saving .
Closest:
https://github.com/tensorflow/tensorflow/issues/616#issuecomment-205620223
"""
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import gfile
from graphviz import Digraph
import torch
from torch.autograd import Variable, Function
def iter_graph(root, callback):
queue = [root]
seen = set()
while queue:
fn = queue.pop()
if fn in seen:
@randomsequence
randomsequence / CompareImages.swift
Last active October 2, 2024 21:09 — forked from ralfebert/CompareImages.swift
A couple of swift functions for comparing two CGImage using CIImage in OS X
//
// Thanks Kevin!
// https://gist.github.com/SheffieldKevin/566dc048dd6f36716bcd
//
import CoreGraphics
import CoreImage
extension CGImage {
import Foundation
import CoreImage
/**
Based on: https://gist.github.com/SheffieldKevin/566dc048dd6f36716bcd
Updated for Swift 5.5 (Xcode 13)
*/
class ImageDiff {
func compare(leftImage: CGImage, rightImage: CGImage) throws -> Int {
@bouroo
bouroo / sse-worker.js
Last active September 1, 2025 20:10
example for cloudflare worker server-sent events
/**
* Cloudflare Worker for Server-Sent Events (SSE)
*
* This worker demonstrates how to set up an SSE endpoint
* that sends an initial message and then periodic updates.
*/
// Listen for incoming requests
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));