Skip to content

Instantly share code, notes, and snippets.

View branislav1991's full-sized avatar

Branislav Holländer branislav1991

View GitHub Profile
@branislav1991
branislav1991 / tensorboard_api.py
Last active July 25, 2019 08:44
Tensorboard API
import io
import numpy as np
from PIL import Image
import tensorflow as tf
class Tensorboard:
def __init__(self, logdir):
self.writer = tf.summary.FileWriter(logdir)
def close(self):
@branislav1991
branislav1991 / siamese.py
Last active February 24, 2021 19:25
Siamese Network For Discriminating MNIST images
import codecs
import errno
import matplotlib.pyplot as plt
import numpy as np
import os
from PIL import Image
import random
import torch
from torch import nn
from torch import optim
import h5py
import helpers
import numpy as np
from pathlib import Path
import torch
from torch.utils import data
class HDF5Dataset(data.Dataset):
"""Represents an abstract HDF5 dataset.
from torch.utils import data
num_epochs = 50
loader_params = {'batch_size': 100, 'shuffle': True, 'num_workers': 6}
dataset = HDF5Dataset('C:/ml/data', recursive=True, load_data=False,
data_cache_size=4, transform=None)
data_loader = data.DataLoader(dataset, **loader_params)
class Player
{
public:
Player() {}
void interactWith(Door *door)
{
if (door)
{
door->toggleOpen();
class Door
{
public:
Door() {}
void toggleOpen()
{
// Open or close the door
m_open = !m_open;
if (m_open)
{
class InteractiveObject
{
public:
virtual void interact() = 0;
virtual ~InteractiveObject() = default;
};
class Door : public InteractiveObject
{
public:
Door() {}
void interact() override
{
// Open or close the door
m_open = !m_open;
if (m_open)
{
class Player
{
public:
Player() {}
void interactWith(InteractiveObject *obj)
{
if (obj)
{
obj->interact();
class Player
{
public:
Player() {}
template <typename InteractiveObject>
void interactWith(InteractiveObject *obj)
{
if (obj)
{