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
def generator(): | |
for factor in np.arange(0.5, 1, 0.01): | |
time = np.arange(0, 50, 0.2) | |
sin: np.ndarray = np.sin(factor * time) + np.random.normal(scale=0.25, size=len(time)) | |
yield sin[:25], sin[25:] | |
time_steps = 25 | |
input_dim = 1 | |
output_dim = 1 |
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
model.compile( | |
optimizer=Adam(), | |
loss='mean_squared_error' | |
) | |
epochs = 25 | |
log_dir='logs' | |
model.fit( | |
train_data, # train dataset that yields (x, y) tuples |
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
time_steps = 50 | |
input_dim = 1 | |
output_dim = 1 | |
dataset = tf.data.Dataset.from_generator( | |
generator=generator, | |
output_types=(tf.float32, tf.float32), | |
output_shapes=(tf.TensorShape([None, time_steps, input_dim]), tf.TensorShape([None, time_steps, output_dim])) | |
) |
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
data = data.prefetch(tf.data.experimental.AUTOTUNE) | |
data = data.cache(filename='tf_data_cache_filename') | |
data = data.shuffle() | |
data = data.batch(batch_size=batch_size, drop_remainder=True) |
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
public class ValidatedObservable : ObservableBase<string> { } | |
public abstract class Validation | |
{ | |
private readonly ValidatedObservable _validatedObservable; | |
private readonly bool _validated; | |
private readonly string _id; | |
private readonly ISet<string> _mustBeValidated; | |
protected Validation(ValidatedObservable validatedObservable, ISet<string> mustBeValidated, bool validated, string id) | |
{ |
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 queue import Queue | |
from threading import Thread | |
class DownloadWorker(Thread): | |
def __init__(self, queue): | |
Thread.__init__(self) | |
self.queue = queue | |
def run(self): | |
while True: |
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
mean = self.get_simple_moving_average(day) | |
derivations = [price - mean for price in self.prices[-day:]] | |
squared_deviations = [numpy.square(derivation) for derivation in derivations] | |
sum_squared_deviations = sum(squared_deviations) | |
return numpy.sqrt(sum_squared_deviations / day) |
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
Exception in thread Thread-8078: | |
Traceback (most recent call last): | |
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 441, in wrap_socket | |
cnx.do_handshake() | |
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1806, in do_handshake | |
self._raise_ssl_error(self._ssl, result) | |
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1538, in _raise_ssl_error | |
raise SysCallError(errno, errorcode.get(errno)) | |
OpenSSL.SSL.SysCallError: (54, 'ECONNRESET') |
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
#!/usr/bin/env python | |
# coding=utf-8 | |
import json | |
import threading | |
from autobahn.twisted.websocket import WebSocketClientFactory, \ | |
WebSocketClientProtocol, \ | |
connectWS | |
from twisted.internet import reactor, ssl |
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
nnoremap <A-q> :m .-2<CR>== | |
nnoremap <A-w> :m .-3<CR>== | |
nnoremap <A-e> :m .-4<CR>== | |
nnoremap <A-r> :m .-5<CR>== | |
nnoremap <A-t> :m .-6<CR>== | |
nnoremap <A-y> :m .-7<CR>== | |
nnoremap <A-u> :m .-8<CR>== | |
nnoremap <A-i> :m .-9<CR>== | |
nnoremap <A-o> :m .-10<CR>== |
NewerOlder