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
# Simplest case (note: VideoDataset.__get__ puts frames on CPU) | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3) | |
fr = d[0] | |
print(type(fr)) | |
print(fr.shape) | |
# Custom processing (note: VideoDataset.__get__ puts frames on CPU) | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, processing={'a': nvvl.ProcessDesc()}) |
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 numpy as np | |
import tensorflow as tf | |
import sys | |
from tensorflow.examples.tutorials.mnist import input_data | |
n_pseudo_batches = int(sys.argv[1]) if len(sys.argv) > 1 else 128 | |
actual_batch_size = int(sys.argv[2]) if len(sys.argv) > 2 else 32 | |
iterations = int(sys.argv[3]) if len(sys.argv) > 3 else 10 |
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 numpy as np | |
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
def simple_model(input): | |
# This ensures that the model will always be instantiated the same, for comparison. | |
hidden_initializer = tf.constant_initializer(np.random.uniform(-0.025, 0.025, size=[784,100])) | |
hidden = tf.layers.dense(input, 100, kernel_initializer=hidden_initializer) | |
out_initializer = tf.constant_initializer(np.random.uniform(-0.025, 0.025, size=[100,10])) |
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 queue | |
import random | |
class RandomQueue(queue.Queue): | |
def _put(self, item): | |
n = len(self.queue) | |
i = random.randint(0, n) | |
self.queue.insert(i, item) |
NewerOlder