- Make base class an
abc.ABC
and specify methods asabstractmethod
orstaticmethod
as much as possible. - Interface function, specify the known/shared arguments as much as possible. Keep the special argument as
**kwargs
.
This file contains hidden or 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
""" | |
This file uses cross validation to tune the parameters. | |
""" | |
import multiprocessing | |
import sys | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt |
This file contains hidden or 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 plot_graph(weights, labels, ax=None): | |
import networkx as nx | |
G = nx.Graph() | |
for i in range(weights.shape[0]): | |
for j in range(weights.shape[1]): | |
if weights[i][j] != 0: | |
G.add_edge(labels[i], labels[j], weight=weights[i][j]) | |
e_pos = [(u, v) for (u, v, d) in G.edges(data=True) if d['weight'] > 0] |
This file contains hidden or 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 matplotlib.dates as mdates | |
plot.hist(mdates.date2num(dts), 100) # plot the histogram | |
ax = plt.gca() | |
ax.xaxis.set_major_locator(mdates.AutoDateLocator()) # set the major ticker, use AutoDateLocator | |
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d')) # show the label | |
ax.xaxis.set_minor_locator(mdates.DayLocator()) # set the minor ticker, use DayLocator |
This file contains hidden or 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
""" | |
The default tf.Print op goes to STDERR | |
Use the function below to direct the output to stdout instead | |
Usage: | |
> x=tf.ones([1, 2]) | |
> y=tf.zeros([1, 3]) | |
> p = x*x | |
> p = tf_print(p, [x, y], "hello") | |
> p.eval() | |
hello [[ 0. 0.]] |
This file contains hidden or 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 abc import ABC, abstractmethod | |
class Foo(ABC, object): | |
@property | |
@abstractmethod | |
def f(self): | |
pass | |
@abstractmethod |
This file contains hidden or 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
channels: | |
- defaults | |
- conda-forge | |
- r | |
- pytorch | |
- derickl | |
dependencies: | |
- python=3.6.9 | |
- dill |
- Disable Ads:
- MacOS:
- (Recommended) Web client + regular ad blocker.
- Regular client + Spotifree: Won't block the ads, but it will automatically mute when ads are being played.
- MacOS:
- Download:
- Downloader: spotify-downloader.com; too good to be true.
This file contains hidden or 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
# the better practice would be always export your data along with the graph | |
# maybe in the future when mpld3.fig_to_json() has been greately improved, | |
# one can simply use this function. | |
fig = ... | |
ax = fig.axes[0] | |
# line | |
line = ax.lines[0] | |
line.set_ydata(line.get_ydata() + 1) |
Some simple (yet not most efficient) solutions:
torchvision.datasets.ImageFolder
/torchvision.datasets.DatasetFolder
+data.DataLoader
lmdb
(Lightning Memory-mapped database manager)
Key technologies:
lapack
for process the dataMagma
suuport: MAGMA is a collection of next generation linear algebra (LA) GPU accelerated libraries designed and implemented by the team that developed LAPACK and ScaLAPACK.
OlderNewer