Skip to content

Instantly share code, notes, and snippets.

💭
Active!

Vivek Maskara maskaravivek

💭
Active!
View GitHub Profile
View user_import.graphql
LOAD CSV WITH HEADERS FROM "https://docs.google.com/spreadsheets/d/e/2PACX-1vRWR2ZZy7YL4s0xSc6dJK1nA4GtVD93yCco35B5ghD6jdLvOUC--f6u_AmtA9Ob1NJn9RrLGjdR8Q04/pub?gid=0&single=true&output=csv" AS line
WITH line, SPLIT(replace(replace(replace(line.wallets, '"', ''), '[', ''), ']', ''), ',') AS wallets
MERGE (user: User {user_id:line.user_id, name:line.name, created_date:date(line.created_at), citizenship_country: line.country})
MERGE (phone_number:PhoneNumber {phone_number: line.phone_number})
MERGE (email:Email {email:line.email})
MERGE (address: Address {address:line.address})
View constrains.graphql
CREATE CONSTRAINT ON (c:Address) ASSERT c.address IS UNIQUE;
CREATE CONSTRAINT ON (c:PhoneNumber) ASSERT c.phone_number IS UNIQUE;
CREATE CONSTRAINT ON (c:Email) ASSERT c.email IS UNIQUE;
CREATE CONSTRAINT ON (c:User) ASSERT c.id IS UNIQUE;
View generator_get.py
x_train, y_train = my_training_batch_generator.__getitem__(0)
print(x_train.shape)
print(y_train.shape)
View model_fit_lr.py
model.fit(## other params
callbacks=[
CustomLearningRateScheduler(lr_schedule)
])
View lr_schedule.py
LR_SCHEDULE = [
# (epoch to start, learning rate) tuples
(0, 0.01),
(75, 0.001),
(105, 0.0001),
]
def lr_schedule(epoch, lr):
"""Helper function to retrieve the scheduled learning rate based on epoch."""
View CustomLearningRateScheduler.py
from tensorflow import keras
class CustomLearningRateScheduler(keras.callbacks.Callback):
def __init__(self, schedule):
super(CustomLearningRateScheduler, self).__init__()
self.schedule = schedule
def on_epoch_begin(self, epoch, logs=None):
if not hasattr(self.model.optimizer, "lr"):
raise ValueError('Optimizer must have a "lr" attribute.')
View custom_loss.py
import tensorflow.keras.backend as k
def custom_loss(y_actual, y_pred):
custom_loss = k.square(y_actual-y_pred)
return custom_loss
View YoloReshape.py
from tensorflow import keras
import keras.backend as K
class YoloReshape(tf.keras.layers.Layer):
def __init__(self, target_shape):
super(YoloReshape, self).__init__()
self.target_shape = tuple(target_shape)
def get_config(self):
config = super().get_config().copy()
View generator_model_fit.py
model.fit(x=my_training_batch_generator,
steps_per_epoch = int(len(X_train) // batch_size),
epochs = 200,
validation_data = my_validation_batch_generator,
validation_steps = int(len(X_test) // batch_size))
View generator_use.py
batch_size = 4
my_training_batch_generator = My_Custom_Generator(X_train, Y_train, batch_size)
my_validation_batch_generator = My_Custom_Generator(X_val, Y_val, batch_size)
You can’t perform that action at this time.