Skip to content

Instantly share code, notes, and snippets.

View innat's full-sized avatar
:octocat:
Working from home

Mohammed Innat innat

:octocat:
Working from home
View GitHub Profile
@innat
innat / CBAM - TF.Keras.py
Last active October 14, 2023 19:03
TF.Keras Implementation of Convolutional Block Attention Module (CBAM)
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',
# 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']
@innat
innat / Path-Analysis-Neo4j-Cypher.md
Last active July 6, 2022 01:38
Path Analytics with CYPHER.

Viewing the graph

match (n:MyNode)-[r]->(m)

return n, r, m

Finding paths between specific nodes:*

@innat
innat / Basic-Queires-Neo4j-Cypher.md
Last active April 9, 2019 18:25
Basic Graph Operations with CYPHER

Basic Graph Operations with CYPHER

Counting the number of nodes

match (n:MyNode)

return count(n)

Counting the number of edges

@innat
innat / Neo4j-Import.md
Created April 9, 2019 18:19
Imported Data into Neo4j

//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)

@innat
innat / Neo4j-Cypher.md
Created April 9, 2019 18:03
Getting Started With Neo4j. Pseudocode to create ‘Toy’ Network

Five Nodes

N1 = Tom

N2 = Harry

N3 = Julian

N4 = Michele

Step by step tuts to setup apache spark ( pyspark ) on linux and setup environment for deep learning with Apache Spark using Deep-Learning-Pipelines.

Step 1 : Install Python 3 and Jupyter Notebook

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

@innat
innat / classifier_from_little_data_script_3.py
Created January 26, 2019 21:05 — forked from fchollet/classifier_from_little_data_script_3.py
Fine-tuning a Keras model. Updated to the Keras 2.0 API.
'''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
@innat
innat / 4Data.md
Created November 12, 2018 18:14
4D - Four Dimensional Data

Let's consider a folowing 4D matrix.

import numpy as np
W = np.random.randn(2,2,3,100)

print(W.shape)

output: