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
# Creating a Tuple | |
a_tuple = (1, 2, 3) | |
# Method 1: Tuple Concatenation | |
a_tuple = a_tuple + (4,) | |
print(a_tuple) | |
# Returns: (1, 2, 3, 4) <- an entirely new object | |
# Method 2: List Conversion |
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 multiprocessor import Pool | |
# multiprocessor.Pool API allows to distribute workload over several processes | |
# Function to apply a function over multiple cores | |
@print_timing | |
def parallel_apply(apply_func, groups, nb_cores): | |
with Pool(nb_cores) as p: | |
results = p.map(apply_func, groups) | |
return pd.concat(results) |
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 encode(num: int): | |
digits = str(num) | |
out = 0 | |
prev = 0 | |
for tmp in digits: | |
tmp = 10 if tmp=='0' else int(tmp) | |
cur_prev = prev | |
prev = tmp |
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 tensorflow.keras.applications.resnet50 import ResNet50 | |
from tensorflow.keras.preprocessing import image | |
from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions | |
import numpy as np | |
# image | |
img_path = 'elephant.jpg' | |
img = image.load_img(img_path, target_size=(224, 224)) | |
x = image.img_to_array(img) | |
x = np.expand_dims(x, axis=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
from tensorflow.keras.applications.vgg16 import VGG16 | |
from tensorflow.keras.applications.vgg19 import VGG19 | |
from tensorflow.keras.preprocessing import image | |
from tensorflow.keras.applications.vgg16 import preprocess_input | |
import numpy as np | |
# image | |
img_path = 'elephant.jpg' | |
img = image.load_img(img_path, target_size=(224, 224)) | |
x = image.img_to_array(img) |
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
## Fine-tune InceptionV3 on a new set of classes | |
from tensorflow.keras.applications.inception_v3 import InceptionV3 | |
from tensorflow.keras.preprocessing import image | |
from tensorflow.keras.models import Model | |
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D | |
# create the base pre-trained model | |
base_model = InceptionV3(weights='imagenet', include_top=False) |
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
# -*- coding: utf-8 -*- | |
""" | |
AlexNet | |
""" | |
import tensorflow as tf | |
import numpy as np | |
from tensorflow.keras.layers import Activation, Conv2D, AveragePooling2D, Dense, Flatten, BatchNormalization, MaxPool2D, Dropout | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.datasets import mnist |
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
# -*- coding: utf-8 -*- | |
""" | |
LeNet - Deep Learning Neural Network | |
""" | |
import tensorflow as tf | |
import numpy as np | |
from tensorflow.keras.layers import Conv2D, AveragePooling2D, Dense, Flatten | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.datasets import mnist |
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.python.platform import build_info as build | |
print(f"tensorflow version: {tf.__version__}") | |
print(f"Cuda Version: {build.build_info['cuda_version']}") | |
print(f"Cudnn version: {build.build_info['cudnn_version']}") |
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
/* | |
A simple jQuery modal (http://github.com/kylefox/jquery-modal) | |
Version 0.9.1 | |
*/ | |
!function(o){"object"==typeof module&&"object"==typeof module.exports?o(require("jquery"),window,document):o(jQuery,window,document)}(function(o,t,i,e){var s=[],l=function(){return s.length?s[s.length-1]:null},n=function(){var o,t=!1;for(o=s.length-1;o>=0;o--)s[o].$blocker&&(s[o].$blocker.toggleClass("current",!t).toggleClass("behind",t),t=!0)};o.modal=function(t,i){var e,n;if(this.$body=o("body"),this.options=o.extend({},o.modal.defaults,i),this.options.doFade=!isNaN(parseInt(this.options.fadeDuration,10)),this.$blocker=null,this.options.closeExisting)for(;o.modal.isActive();)o.modal.close();if(s.push(this),t.is("a"))if(n=t.attr("href"),this.anchor=t,/^#/.test(n)){if(this.$elm=o(n),1!==this.$elm.length)return null;this.$body.append(this.$elm),this.open()}else this.$elm=o("<div>"),this.$body.append(this.$elm),e=function(o,t){t.elm.remove()},this.showSpinner(),t.trigger(o.modal.AJAX_SEND),o.get(n).done(function(i){if(o.m |
NewerOlder