Skip to content

Instantly share code, notes, and snippets.

@panmari
panmari / conv_summary.py
Last active January 15, 2019 14:54
Tensorflow visualize convolutions
channels = 32
img_size = 128
W_conv1 = weight_variable([5, 5, 1, channels])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1))
# Produces a tensor of size [-1, img_size, img_size, channels]
## Prepare for visualization
# Take only convolutions of first image, discard convolutions for other images.
V = tf.slice(h_conv1, (0, 0, 0, 0), (1, -1, -1, -1), name='slice_first_input')
import tensorflow as tf
import copy
epochs = 5
filename_seed = 4
capacity = 32
batch_size = 255
import string
import random
@panmari
panmari / postgresql_random_retrieve.rb
Last active May 11, 2018 10:59
Benchmark of various methods to retrieve a random record from a table using ActiveRecord and a Postgresql db behind.
require 'benchmark'
# Disable logging if in development/test mode
ActiveRecord::Base.logger = nil
model_name = Icd
N = 100
Benchmark.bm(11) do |x|
x.report('ruby rand') { N.times { model_name.offset(rand(model_name.count)).first } }
@panmari
panmari / benchmarks.log
Created March 16, 2017 19:23
Benchmark for resize nearest neighbor on cpu
# Benchmarks for images with 6 channels.
# Full command line:
# bazel run -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda tensorflow/core/kernels:resize_benchmark_test_gpu -- --benchmarks=..
BEFORE
Benchmark Time(ns) Iterations
--------------------------------------------------------------------
BM_Resize_ResizeNearestNeighbor_cpu_10_499_499 50546710 100 295.6M items/s
BM_Resize_ResizeNearestNeighbor_gpu_10_499_499 9572830 100 1560.7M items/s
BM_Resize_ResizeBilinear_cpu_10_499_499 64680780 100 231.0M items/s
BM_Resize_ResizeBilinear_gpu_10_499_499 11350100 100 1316.3M items/s
@panmari
panmari / gist:6579977
Last active December 23, 2015 04:19
jrtr getting started notes

General tips

  • Install the source/javadoc for eclipse built in documentation (right click on project -> Maven -> download source).
  • Manually add the documentation for vecmath (simple project -> maven dependancies -> vecmath-1.3.1.jar rightclick -> properties -> add http://download.java.net/media/java3d/javadoc/1.5.0/ under javadoc location path.

Linux

Nvidia graphics card

@panmari
panmari / elastic_search_parallel
Created August 28, 2013 09:14
Starting two queries to the elasticsearch server through the Tire gem. Even though the long, complicated query starts before the short one, the short one is returned first.
# try this in a rails environment, that has the Indexing module loaded. (medcode, orangeproton)
search_queries = ["Ein sehr komplizierter query, der sehr lange zum ausfuhren braucht", "kurz"] # !sic
threads = []
search_queries.each do |string|
threads << Thread.new(string) do |query|
puts "started #{query}"
Indexing.elastic_find_all(string, 'icd', '2012', 'ch', 'de')
puts "finished #{query}"
end
@panmari
panmari / build.log
Last active December 17, 2015 20:18
/usr/bin/cmake -H/home/panmari/oiio -B/home/panmari/oiio/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/panmari/oiio/build/CMakeFiles /home/panmari/oiio/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/panmari/oiio/build'
make -f src/libutil/CMakeFiles/OpenImageIO_Util.dir/build.make src/libutil/CMakeFiles/OpenImageIO_Util.dir/depend
make[2]: Entering directory '/home/panmari/oiio/build'
cd /home/panmari/oiio/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/panmari/oiio /home/panmari/oiio/src/libutil /home/panmari/oiio/build /home/panmari/oiio/build/src/libutil /home/panmari/oiio/build/src/libutil/CMakeFiles/OpenImageIO_Util.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/panmari/oiio/build'
make -f src/libutil/CMakeFiles/OpenImageIO_Util.dir/build.make src/libutil/CMakeFiles/OpenImageIO_Util.dir/build
make[2]: Entering directory '/home/panmari/oiio/build'
@panmari
panmari / CMakeCache.txt
Last active December 17, 2015 19:54
oiio build on ubuntu 15.10
# This is the CMakeCache file.
# For build in directory: /home/panmari/oiio/build
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
# Using opencv for borderless cloning.
import cv2
import numpy as np
# Read images : src image will be cloned into dst
im_filename = "wolf.jpg"
im = cv2.imread(im_filename)
obj= cv2.flip(cv2.imread("hamster.jpg"), 1)
mask = cv2.flip(cv2.imread("hamster_mask.png"), 1)
mask = cv2.cvtColor(mask, cv2.COLOR_RGB2GRAY)
@panmari
panmari / Output_linux_gcc4.8.txt
Last active October 14, 2015 17:34
Testing performance of different ways to divide a 3d image by a 1d image channel wise. See also http://stackoverflow.com/questions/33098797/divide-every-channel-of-image-by-weight-image-in-opencv
OpenCV version: 3.0.0-dev
OpenCV VCS version: 3.0.0-556-g33f5ac5
Build type: release
Parallel framework: pthreads
CPU features: mmx sse sse2 sse3
OpenCL Platforms:
NVIDIA CUDA
dGPU: GeForce GTX TITAN (OpenCL 1.2 CUDA)
Current OpenCL device:
Type = dGPU