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 | |
from tensorflow.keras import layers, models | |
from tensorflow.keras.datasets import cifar10 | |
import time | |
# Load CIFAR-10 dataset | |
(train_images, train_labels), (test_images, test_labels) = cifar10.load_data() | |
# Normalize pixel values to be between 0 and 1 | |
train_images, test_images = train_images / 255.0, test_images / 255.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 io | |
import os | |
import tqdm | |
import argparse | |
import numpy as np | |
import pandas as pd | |
import tensorflow as tf | |
from utils import styled_print | |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' |
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
{ | |
"embeddings": [ | |
{ | |
"tensorName": "Fire and Blood - Word2Vec", | |
"tensorShape": [ | |
300, | |
13693 | |
], | |
"tensorPath": "https://gist.githubusercontent.com/viralbthakar/b2d318565ae4a628dbecba6ee39fbf11/raw/4441c894b9d52797ee2cef9b6c914b57f7ef2cda/vectors.tsv", | |
"metadataPath": "https://gist.githubusercontent.com/viralbthakar/2c3c8469931b07a36ffe05f3ba0128f6/raw/12c18b0763866f6a177959514892f269e45d0f63/metadata.tsv" |
We can't make this file beautiful and searchable because it's too large.
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
-0.048866298 -0.0016785637 0.0038877502 0.0040101036 0.033698905 0.022059526 0.027706925 -0.03167452 0.02778678 -0.022080792 0.043521475 -0.0018232353 -0.0047206506 0.022144224 0.04939803 0.022760537 -0.008644424 -0.016616572 0.0220027 -0.026030077 -0.020085013 -0.035149373 -0.046827864 0.011195052 0.020963196 0.00949068 0.034231115 -0.037880994 -0.0024146214 -0.031831015 0.013744149 -0.021530164 -0.03460578 0.0068220496 -0.026724327 -0.03672732 0.0036778934 0.02596232 -0.008625388 -0.026180243 0.030728605 -0.033938088 0.01160755 0.008664608 0.044776943 0.044101965 -0.042550564 0.04983506 -0.023614382 0.009385873 0.045363855 0.00018430874 0.008923959 0.019788656 0.0208782 -0.008075904 0.014386807 -0.0077568777 0.03852633 0.030512046 -0.013017915 0.014862601 0.006768964 0.03516427 0.0016545281 0.04538654 -0.043342542 0.04143813 -0.02258116 -0.016876448 -0.035590887 0.019355956 -0.04687668 0.014895808 -0.031816438 0.02420688 0.000644695 -0.020795071 0.045877267 0.022969197 0.03598148 -0.046948362 0.0031965002 - |
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 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
[UNK] | |
’ | |
“ | |
” | |
The | |
Lord | |
Rhaenyra | |
would | |
King | |
Ser |
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 os | |
import random | |
import numpy as np | |
import tensorflow as tf | |
import matplotlib.pyplot as plt | |
from tensorflow.keras.layers import Input, Convolution2D, MaxPooling2D, Activation, Dense, Flatten | |
from tensorflow.keras.models import Model | |
#Set The Parametes | |
DATA_DIR = "./data" |
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 get_model_arch(input_shape, last_layer_nodes=1000, last_layer_activation='sigmoid'): | |
input_img = Input(input_shape, name='input') | |
x = Convolution2D(64, (3, 3), activation='relu', padding='same', name='fe0_conv1')(input_img) | |
x = Convolution2D(64, (3, 3), activation='relu', padding='same', name='fe0_conv2')(x) | |
x = MaxPooling2D((2, 2), padding='same', name='fe0_mp')(x) | |
x = Convolution2D(128, (3, 3), activation='relu', padding='same', name='fe1_conv1')(x) | |
x = Convolution2D(128, (3, 3), activation='relu', padding='same', name='fe1_conv2')(x) | |
x = MaxPooling2D((2, 2), padding='same', name='fe1_mp')(x) | |
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 | |
def get_img_file(img_path, input_shape): | |
image = tf.io.read_file(img_path) | |
image = tf.image.decode_jpeg(image, channels=3) | |
image = tf.image.resize(image, [input_shape[0], input_shape[1]], antialias=True) | |
image = tf.cast(image, tf.float32)/255.0 | |
return image | |
def parse_function(ip_dict, input_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
def get_per_class_image_list(image_dir, image_list, class_name, split_iden=".", split_iden_index=0, shuffle=True): | |
class_name_image_list = [os.path.join(image_dir, image_file) for image_file in image_list if image_file.split(split_iden)[split_iden_index] == class_name] | |
if shuffle: | |
random.shuffle(class_name_image_list) | |
print("For Class {} Found {} Images".format(class_name, len(class_name_image_list))) | |
return class_name_image_list | |
def split_data(image_dir, image_list, class_list, split_index): | |
train_data_dict = {"images":[], "labels":[]} | |
val_data_dict = {"images":[], "labels":[]} |