This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
{ | |
public: | |
Player() {} | |
void interactWith(Door *door) | |
{ | |
if (door) | |
{ | |
door->toggleOpen(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Door | |
{ | |
public: | |
Door() {} | |
void toggleOpen() | |
{ | |
// Open or close the door | |
m_open = !m_open; | |
if (m_open) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InteractiveObject | |
{ | |
public: | |
virtual void interact() = 0; | |
virtual ~InteractiveObject() = default; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Door : public InteractiveObject | |
{ | |
public: | |
Door() {} | |
void interact() override | |
{ | |
// Open or close the door | |
m_open = !m_open; | |
if (m_open) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
{ | |
public: | |
Player() {} | |
void interactWith(InteractiveObject *obj) | |
{ | |
if (obj) | |
{ | |
obj->interact(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
{ | |
public: | |
Player() {} | |
template <typename InteractiveObject> | |
void interactWith(InteractiveObject *obj) | |
{ | |
if (obj) | |
{ |
OlderNewer