Skip to content

Instantly share code, notes, and snippets.

View keineahnung2345's full-sized avatar
:octocat:
Focusing

keineahnung2345

:octocat:
Focusing
View GitHub Profile
@michaellihs
michaellihs / tmux-cheat-sheet.md
Last active July 20, 2025 09:15
tmux Cheat Sheet
@cbaziotis
cbaziotis / Attention.py
Last active October 22, 2024 08:31
Keras Layer that implements an Attention mechanism for temporal data. Supports Masking. Follows the work of Raffel et al. [https://arxiv.org/abs/1512.08756]
from keras import backend as K, initializers, regularizers, constraints
from keras.engine.topology import Layer
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
@buoto
buoto / .editorconfig
Created April 15, 2017 20:15
Editorconfig for C/C++ project
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
from matplotlib import pyplot as plt
import cv2
img = cv2.imread('/Users/mustafa/test.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(gray)
plt.title('my picture')
plt.show()
@mrry
mrry / tensorflow_self_check.py
Last active September 26, 2024 15:39
[DEPRECATED] TensorFlow on Windows self-check
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@kevinzakka
kevinzakka / data_loader.py
Last active March 16, 2025 18:14
Train, Validation and Test Split for torchvision Datasets
"""
Create train, valid, test iterators for CIFAR-10 [1].
Easily extended to MNIST, CIFAR-100 and Imagenet.
[1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4
"""
import torch
import numpy as np
@ruslangrimov
ruslangrimov / keras-tensorflow-model-profiling.py
Last active October 15, 2019 20:51
Profiling a Keras-TensorFlow model
import tensorflow as tf
from tensorflow.python.client import timeline
from keras import backend as K
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
model = ... # A Keras model
fn = K.function(model.inputs, model.outputs, options=run_options, run_metadata=run_metadata)
@hsinewu
hsinewu / kmp.cpp
Last active May 17, 2021 11:34
Knuth–Morris–Pratt algorithm in c++
#include <iostream>
#include <algorithm>
using namespace std;
int find_substring(string str, string pattern) {
// Step 0. Should not be empty string
if( str.size() == 0 || pattern.size() == 0)
return -1;
@maxim5
maxim5 / pretrained_word2vec_lstm_gen.py
Last active July 2, 2023 10:40
Text generator based on LSTM model with pre-trained Word2Vec embeddings in Keras
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
__author__ = 'maxim'
import numpy as np
import gensim
import string
@atinfinity
atinfinity / gpumat_memory_performance.cpp
Last active December 5, 2019 10:21
GpuMatのcudaMallocPitchが遅くなる再現コード
#include <opencv2/core.hpp>
#include <opencv2/core/cuda.hpp>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <iostream>
int main(int argc, const char * argv[])
{
cudaFree(0); // dummy call