Skip to content

Instantly share code, notes, and snippets.

View kostyaev's full-sized avatar

Dmitry Kostyaev kostyaev

View GitHub Profile
@kostyaev
kostyaev / losses.py
Created November 11, 2020 13:25
Losses and metrics
def euler_loss(y_true, y_pred):
dist1 = tf.abs(y_true - y_pred)
dist2 = tf.abs(2*np.pi + y_true - y_pred)
dist3 = tf.abs(-2*np.pi + y_true - y_pred)
loss = tf.where(dist1<dist2, dist1, dist2)
loss = tf.where(loss<dist3, loss, dist3)
return tf.reduce_mean(loss)
def quaternion_loss(y_true, y_pred):
dist1 = tf.reduce_mean(tf.abs(y_true-y_pred), axis=-1)
@kostyaev
kostyaev / data.py
Last active November 13, 2020 11:28
Data generation
def get_R(angles):
''' Get rotation matrix from three rotation angles (radians). right-handed.
Args:
angles: [3,]. x, y, z angles
Returns:
R: [3, 3]. rotation matrix.
'''
x, y, z = angles.astype(np.float32)
# x
Rx = np.array([[1, 0, 0],
@kostyaev
kostyaev / multinomial_train_val.prototxt
Created October 15, 2016 10:09
Multinomial net definition example for caffe
name: "VGG_CNN_M_128"
layer {
name: "data"
type: "Data"
top: "data"
include {
phase: TRAIN
}
transform_param {
mirror: true
@kostyaev
kostyaev / jboss.conf
Created March 2, 2015 11:39
JBoss Logstash Configuration
input {
file {
path => "/opt/jboss-as/standalone/log/server.log"
start_position => end
add_field => { "host" => "test" }
codec => multiline {
pattern => "^\d\d:\d\d:\d\d,\d\d\d"
negate => true
what => "previous"
}
@kostyaev
kostyaev / readme
Created October 7, 2014 10:01
Remove old elasticsearch index
create file with the following content and set timer to run this script every day:
> crontab -e
add this line to the end of file:
* * */1 * * /etc/elasticsearch/logstash-delete-index.sh -i 3
-i 3 will remain 3 most recent indecies for you
#!/bin/bash
# elasticsearch-remove-old-indices.sh
@kostyaev
kostyaev / jboss-logstash.conf
Last active November 11, 2019 13:09
Logstash config for JBoss AS 7
input {
file {
path => "/Users/virtuozzo/Servers/jboss-as-7.1.1.Final/standalone/log/server.log"
start_position => end
}
}
filter {
mutate { replace => { "type" => "local-jboss" } }
grok {
@kostyaev
kostyaev / javaversion.sh
Created July 17, 2014 11:32
Change Java version on Mac OS X
vi ~/.bash_profile
add
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
This tells your /usr/bin/java link target to use the latest Java 7 Package installed in
/Library/Java/JavaVirtualMachines/
@kostyaev
kostyaev / jekyll_install
Created June 17, 2014 21:34
Install Jekyll on Ubuntu 13.10
apt-get install ruby1.9.1-dev
apt-get install rubygems
gem install jekyll
apt-get install nodejs
@kostyaev
kostyaev / cyrilic.tex
Last active August 29, 2015 14:02
TeX cyrillic example
\documentclass[a4paper,12pt]{article}
\usepackage[utf8x]{inputenc} % more recent versions (at least>=2004-17-10)
\usepackage[russian]{babel}
\author{A. S. Pushkin}
\title{Зимнее утро (winter morning)}