Skip to content

Instantly share code, notes, and snippets.

View ajinkyajawale14499's full-sized avatar
🎯
Focusing

Ajinkya ajinkyajawale14499

🎯
Focusing
View GitHub Profile
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')
])
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')
print (train_generator.class_indices)
labels = '\n'.join(sorted(train_generator.class_indices.keys()))
with open('labels.txt', 'w') as f:
f.write(labels)
for image_batch, label_batch in train_generator:
break
image_batch.shape, label_batch.shape
@ajinkyajawale14499
ajinkyajawale14499 / rescale.py
Created July 8, 2019 19:25
rescaling the images
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),
_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')
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.
@ajinkyajawale14499
ajinkyajawale14499 / stack.cpp
Created July 7, 2019 09:06
Shorten the string which same adjacent 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){
@ajinkyajawale14499
ajinkyajawale14499 / largest_histogram_divide&conquer.java
Created June 29, 2019 18:51
largest_histogram_divide&conquer
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;