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 SpatialAttentionModule(tf.keras.layers.Layer): | |
def __init__(self, kernel_size=3): | |
''' | |
paper: https://arxiv.org/abs/1807.06521 | |
code: https://gist.github.com/innat/99888fa8065ecbf3ae2b297e5c10db70 | |
''' | |
super(SpatialAttentionModule, self).__init__() | |
self.conv1 = tf.keras.layers.Conv2D(64, kernel_size=kernel_size, | |
use_bias=False, | |
kernel_initializer='he_normal', |
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
# set plot figure size | |
fig, c_ax = plt.subplots(1,1, figsize = (12, 8)) | |
def multiclass_roc_auc_score(y_test, y_pred, average="macro"): | |
lb = LabelBinarizer() | |
lb.fit(y_test) | |
y_test = lb.transform(y_test) | |
y_pred = lb.transform(y_pred) | |
for (idx, c_label) in enumerate(all_labels): # all_labels: no of the labels, for ex. ['cat', 'dog', 'rat'] |
Viewing the graph
match (n:MyNode)-[r]->(m)
return n, r, m
Finding paths between specific nodes:*
Basic Graph Operations with CYPHER
Counting the number of nodes
match (n:MyNode)
return count(n)
Counting the number of edges
//One way to "clean the slate" in Neo4j before importing (run both lines):
match (a)-[r]->() delete a,r
match (a) delete a
//Script to Import Data Set: test.csv (simple road network)
Step by step tuts to setup apache spark ( pyspark ) on linux and setup environment for deep learning with Apache Spark using Deep-Learning-Pipelines.
Run following command. Someone may need to install pip first or any missing packages may need to download.
sudo apt install python3-pip
sudo pip3 install jupyter
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
'''This script goes along the blog post | |
"Building powerful image classification models using very little data" | |
from blog.keras.io. | |
It uses data that can be downloaded at: | |
https://www.kaggle.com/c/dogs-vs-cats/data | |
In our setup, we: | |
- created a data/ folder | |
- created train/ and validation/ subfolders inside data/ | |
- created cats/ and dogs/ subfolders inside train/ and validation/ | |
- put the cat pictures index 0-999 in data/train/cats |
Let's consider a folowing 4D matrix.
import numpy as np
W = np.random.randn(2,2,3,100)
print(W.shape)
output: