remove Docker container
docker rm tf
stop the container
docker stop tf
def softmax(class_scores): | |
""" | |
Calculate class probability distribution for each digit from given class scores. | |
:param class_scores: class scores of your function | |
:return: probability distribution | |
""" | |
class_scores -= np.max(class_scores) | |
return np.exp(class_scores) / np.sum(np.exp(class_scores),axis=1, keepdims=True) | |
# this implementation was given as assignment 3 of the course | |
# B55.2 WT Ausgewählte Kapitel sozialer Webtechnologien at HTW Berlin | |
# third party | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# internal | |
from deep_teaching_commons.data.fundamentals.mnist import Mnist |
import cv2 | |
# open video | |
video = cv2.VideoCapture('video.mp4') | |
# get fps and duration | |
fps = video.get(cv2.CAP_PROP_FPS) # OpenCV2 version 2 used "CV_CAP_PROP_FPS" | |
frameCount = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) | |
duration = frameCount/fps |
def minibatcher(inputs, targets, batchsize, shuffle=False): | |
assert len(inputs) == len(targets) | |
if shuffle: | |
indices = np.arange(len(inputs)) | |
np.random.shuffle(indices) | |
for start_idx in range(0, len(inputs) - batchsize + 1, batchsize): | |
if shuffle: | |
excerpt = indices[start_idx:start_idx + batchsize] | |
else: | |
excerpt = slice(start_idx, start_idx + batchsize) |
import tensorflow as tf | |
def get_weight(shape, name, trainable=True): | |
#initial = tf.random_uniform(shape, minval=-0.1, maxval = 0.1) | |
initial = tf.contrib.layers.xavier_initializer()(shape) | |
return tf.Variable(initial, trainable=trainable, name=name+'_W', dtype=tf.float32) | |
def get_bias(shape, name, trainable=True): | |
""" | |
filter_height, filter_width, in_channels, out_channels] |
import matplotlib.pyplot as plt | |
# plot 0 plot 1 plot 2 plot 3 | |
x=[[1,2,3,4],[1,4,3,4],[1,2,3,4],[9,8,7,4]] | |
y=[[3,2,3,4],[3,6,3,4],[6,7,8,9],[3,2,2,4]] | |
plots = zip(x,y) | |
figs={} | |
axs={} | |
for idx,plot in enumerate(plots): | |
figs[idx]=plt.figure() |
export JAVA_7_HOME=$(/usr/libexec/java_home -v1.7) | |
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8) | |
export JAVA_9_HOME=$(/usr/libexec/java_home -v9) | |
alias java7='export JAVA_HOME=$JAVA_7_HOME' | |
alias java8='export JAVA_HOME=$JAVA_8_HOME' | |
alias java9='export JAVA_HOME=$JAVA_9_HOME' | |
#default java8 | |
export JAVA_HOME=$JAVA_8_HOME |
remove Docker container
docker rm tf
stop the container
docker stop tf
plt.figure(figsize=(20, 20)) | |
num_classes = 10 | |
for c in range(num_classes): | |
# Select samples_per_class random keys of the labels == current class | |
keys = np.random.choice(np.where(label == c)[0], examples_each_row) | |
images = data[keys] | |
labels = label[keys] | |
for i in range(examples_each_row): | |
f = plt.subplot(examples_each_row, num_classes, i * num_classes + c + 1) |