Skip to content

Instantly share code, notes, and snippets.

View Higgcz's full-sized avatar
:octocat:

Vojtech Micka Higgcz

:octocat:
  • NNAISENSE
  • Lugano
View GitHub Profile
@Higgcz
Higgcz / model.py
Created September 21, 2016 09:02
Keras 1.1.0 - Model
# Create simple model
model = Sequential()
model.add(TimeDistributed(Convolution2D(32, 3, 3, border_mode='same'), input_shape = batch_input_shape[1:]))
model.add(Activation('relu'))
model.add(TimeDistributed(MaxPooling2D(pool_size = (2,2))))
model.add(BatchNormalization())
model.add(TimeDistributed(Convolution2D(32, 3, 3, border_mode='same')))
model.add(Activation('relu'))
@Higgcz
Higgcz / Stacktrace
Last active September 21, 2016 09:23
Keras 1.1.0 - Error with TimeDistributed wrapper
ValueError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/framework/tensor_shape.py in merge_with(self, other)
562 try:
--> 563 self.assert_same_rank(other)
564 new_dims = []
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/framework/tensor_shape.py in assert_same_rank(self, other)
608 raise ValueError(
--> 609 "Shapes %s and %s must have the same rank" % (self, other))
610
@Higgcz
Higgcz / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
%% -------------------------------------------------------------------------
% ( 9 ) Inference & missing values
% -------------------------------------------------------------------------
% Create inference engine
engine = jtree_inf_engine ( bnet );
% Sort brokenData to right order
brokenDataSorted = brokenData ( bnet.ordering, : )';
@Higgcz
Higgcz / DifferentElements.c++
Last active December 31, 2015 04:39
Count number of different letters in word in array.
inline unsigned calcStates () {
unsigned numStates = (unsigned) substrings[0].size() + 1;
Word str1, str2;
for ( vector<Word>::iterator str = substrings.begin(); (str+1) != substrings.end(); ) {
str1 = *str;
str2 = *(++str);
unsigned i = 0;
while (str1[i] == str2[i] && i < str1.size()) i++;
@Higgcz
Higgcz / montage.m
Created December 6, 2012 19:07
Montage functiong for displaying multiple images as grid
function montage(images, varargin)
%MONTAGE Display multiple images as grid
%
% Synopsis:
% MYMONTAGE(images)
% MYMONTAGE(...,PARAM1,VAL1,PARAM2,VAL2,...) displays the image, specifying
% parameters and corresponding values that control various aspects of the
% image display. Parameter names can be abbreviated, and case does not matter.
%
% Parameters include:
@Higgcz
Higgcz / UIColor+HashParser.h
Created November 20, 2012 00:15
I made a category on UIColor which allows to create color from hex code (eg.: #498ea8). I have tried to use different methods to get number from hex string, but all of them was to slow, something about 0.022 - 0.040 ms. This is the fastest way I've found
//
// UIColor+HashParser.h
//
// Created by Vojtech Micka on 11/19/12.
// Copyright (c) 2012 All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (HexParser)
@Higgcz
Higgcz / perceptron.m
Created November 7, 2012 18:07
Simple Perceptron algorithm which divide the input space with a linear decision boundary.
function [ model ] = perceptron( data, options )
%PERCEPTRON
%
% INPUT:
% data : struct [ 1xn ] data for training the classifier
% .X
% .y
% limit : int [ 1x1 ] maximum number of iteration
% options : struc [ --- ]
% .limit : int [ 1x1 ] maximum number of iteration
@Higgcz
Higgcz / gist:3995814
Created November 1, 2012 19:17
Log likelihood function (normal distribution)
covGen = (0.5:0.001:2.5) * 10e2;
for s=1:size(covGen,2),
L(s) = sum(log(normpdf(measurmentX1, Model.Mean, covGen(s))));
end;
@Higgcz
Higgcz / gist:3989390
Created October 31, 2012 19:52
Parzen function which computes for a given x an estimation of probability p(x).
function y = my_parzen(x, X, sigma, method)
if ( ~exist('method', 'var') ),
method = 'method';
end;
n = length(X);
y = zeros(length(x), 1);
switch method