This file contains hidden or 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
model = tf.keras.Sequential([ | |
base_model, | |
tf.keras.layers.Conv2D(32, 3, activation='relu'), | |
tf.keras.layers.Dropout(0.2), | |
tf.keras.layers.GlobalAveragePooling2D(), | |
tf.keras.layers.Dense(5, activation='softmax') | |
]) |
This file contains hidden or 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
IMG_SHAPE = (IMAGE_SIZE, IMAGE_SIZE, 3) | |
# Create the base model from the pre-trained model MobileNet V2 | |
base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE, | |
include_top=False, | |
weights='imagenet') |
This file contains hidden or 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
print (train_generator.class_indices) | |
labels = '\n'.join(sorted(train_generator.class_indices.keys())) | |
with open('labels.txt', 'w') as f: | |
f.write(labels) |
This file contains hidden or 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
for image_batch, label_batch in train_generator: | |
break | |
image_batch.shape, label_batch.shape |
This file contains hidden or 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
IMAGE_SIZE = 224 | |
BATCH_SIZE = 64 | |
datagen = tf.keras.preprocessing.image.ImageDataGenerator( | |
rescale=1./255, | |
validation_split=0.2) | |
train_generator = datagen.flow_from_directory( | |
base_dir, | |
target_size=(IMAGE_SIZE, IMAGE_SIZE), |
This file contains hidden or 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
_URL = "https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz" | |
zip_file = tf.keras.utils.get_file(origin=_URL, | |
fname="flower_photos.tgz", | |
extract=True) | |
base_dir = os.path.join(os.path.dirname(zip_file), 'flower_photos') |
This file contains hidden or 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 __future__ import absolute_import, division, print_function, unicode_literals | |
!pip install tf-nightly-gpu-2.0-preview | |
import tensorflow as tf | |
import os | |
import numpy as np | |
import matplotlib.pyplot as plt |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
#include <iostream> | |
#include <algorithm> | |
#include <bits/stdc++.h> | |
#include <stack> | |
using namespace std; | |
// logic is each time character is pushed over stack will be checked with following character if it same continue else print the char | |
void calculate(string str){ | |
This file contains hidden or 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
class Solution { | |
int maxCombineArea(const vector<int> &height, int s, int m, int e) { | |
// Expand from the middle to find the max area containing height[m] and height[m+1] | |
int i = m, j = m+1; | |
int area = 0, h = min(height[i], height[j]); | |
while(i >= s && j <= e) { | |
h = min(h, min(height[i], height[j])); | |
area = max(area, (j-i+1) * h); | |
if (i == s) { | |
++j; |