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 init_weights(shape): | |
""" Weight initialization """ | |
weights = tf.random_normal(shape, stddev=0.1) | |
return tf.Variable(weights) | |
def init_bias(shape): | |
"""Create a bias variable with appropriate initialization.""" | |
initial = tf.constant(0.1, shape=shape) |
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 keras.applications import VGG16 | |
from keras.layers import Dropout, Flatten, Dense | |
from keras.applications.vgg16 import preprocess_input | |
from keras.preprocessing import image as kimage | |
from keras.models import Model | |
from keras.utils import to_categorical | |
import numpy as np | |
import pandas as pd | |
''' This file reads from a csv file the paths of the images and its corresponding labels (in my case |
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
import tensorflow as tf | |
import numpy as np | |
def cosine_similarity(matrix, vector): | |
''' Computes cosine similarity of a given vector with vector rows from matrix''' | |
# normalize input | |
norm_matrix = tf.nn.l2_normalize(matrix, 1) | |
norm_vector = tf.nn.l2_normalize(vector, 0) |
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
import pyodbc | |
from subprocess import run, CalledProcessError | |
import os | |
from string import Template | |
import pandas as pd | |
''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''' | |
''' DATABASE CONNECTION FILE (keep it simple) ''' | |
''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''' |