Skip to content

Instantly share code, notes, and snippets.

View bkocis's full-sized avatar
:octocat:
diving in time

Balazs Kocsis bkocis

:octocat:
diving in time
View GitHub Profile
@bkocis
bkocis / Deep Reinforcement Learning ND exercises.md
Last active November 4, 2019 16:44
Deep Reinforcement Learning ND exercises

Deep Q-Network (DQN)

example of LunarLander-v2 environment deom OpenAi Gym.

import gym
!pip3 install box2d
import random
import torch
import numpy as np
from collections import deque
@bkocis
bkocis / spark_02.md
Last active October 18, 2019 16:07
spark maps and lazy evalution

Spark context and spark session

import pyspark
sc = pyspark.SparkContext(appName="maps_and_lazy_evaluation_example")

log_of_songs = [
        "Despacito",
        "Nice for what",
 "No tears left to cry",
@bkocis
bkocis / spark_01.md
Last active October 18, 2019 15:36
mapReduce in spark

Code snippets from Udacity Spark Course

MapReduce

The biggest difference between Hadoop and Spark is that Spark tries to do as many calculations as possible in memory, which avoids moving data back and forth across a cluster. Hadoop writes intermediate calculations out to disk, which can be less efficient. Hadoop is an older technology than Spark and one of the cornerstone big data technologies.

MapReduce versus Hadoop MapReduce

@bkocis
bkocis / RNN-s_LSTMS.md
Created September 23, 2019 23:06
Collection of RNN and LSTM network architectures

example 1 / from the CVND Image captioning project

class DecoderRNN(nn.Module):
    def __init__(self, embed_size, hidden_size, vocab_size, num_layers=1, dropout=0):
        super().__init__()
        self.embed_size = embed_size
        self.hidden_size = hidden_size
        self.vocab_size = vocab_size

model class of CNN in PyToch

#  with batch normalization, dropout layer and 3 convolutional layers

import torch.nn as nn
import torch.nn.functional as F

# define the CNN architecture

Finding Contours Fit Ellipse Crop selected contour based on angle of ellips

import numpy as np
import matplotlib.pyplot as plt
import cv2

Harris corner detection

Detect corners

import matplotlib.pyplot as plt
import numpy as np
import cv2

Canny Edge Detection

Hough Line Detection

import numpy as np
import matplotlib.pyplot as plt
import cv2

Load image apply high-pass filter apply fourier tr

import numpy as np
import matplotlib.pyplot as plt
import cv2

# Read in an image