Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions Framework/Keras/Keras Assingment/Harsh_Task1/harsh.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"from keras.utils.np_utils import to_categorical"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"from keras.datasets import mnist"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"from keras.layers import Dense"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"from keras.models import Sequential"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"from keras.callbacks import CSVLogger"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"(X_train, Y_train),(X_test, Y_test) = mnist.load_data()"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"model = Sequential()"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"X_train = X_train.reshape(X_train.shape[0],784)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"X_test = X_test.reshape(X_test.shape[0], 784)\n"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"X_train = X_train / 255\n",
"X_test = X_test / 255"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"Y_train = to_categorical(Y_train)\n",
"Y_test = to_categorical(Y_test)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"model.add(Dense(512,input_dim = 784 ,activation = 'relu'))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"model.add(Dense(10,activation = 'softmax'))"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
"model.compile(optimizer = 'adam',loss = 'categorical_crossentropy', metrics=['accuracy'])"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 60000 samples, validate on 10000 samples\n",
"Epoch 1/10\n",
" - 9s - loss: 0.2155 - acc: 0.9375 - val_loss: 0.1092 - val_acc: 0.9667\n",
"Epoch 2/10\n",
" - 8s - loss: 0.0855 - acc: 0.9741 - val_loss: 0.0788 - val_acc: 0.9757\n",
"Epoch 3/10\n",
" - 8s - loss: 0.0547 - acc: 0.9832 - val_loss: 0.0802 - val_acc: 0.9748\n",
"Epoch 4/10\n",
" - 10s - loss: 0.0395 - acc: 0.9875 - val_loss: 0.0900 - val_acc: 0.9727\n",
"Epoch 5/10\n",
" - 11s - loss: 0.0285 - acc: 0.9907 - val_loss: 0.0681 - val_acc: 0.9796\n",
"Epoch 6/10\n",
" - 9s - loss: 0.0215 - acc: 0.9927 - val_loss: 0.0669 - val_acc: 0.9799\n",
"Epoch 7/10\n",
" - 9s - loss: 0.0166 - acc: 0.9949 - val_loss: 0.0857 - val_acc: 0.9759\n",
"Epoch 8/10\n",
" - 8s - loss: 0.0146 - acc: 0.9953 - val_loss: 0.0830 - val_acc: 0.9764\n",
"Epoch 9/10\n",
" - 8s - loss: 0.0107 - acc: 0.9965 - val_loss: 0.0695 - val_acc: 0.9833\n",
"Epoch 10/10\n",
" - 9s - loss: 0.0089 - acc: 0.9972 - val_loss: 0.0844 - val_acc: 0.9795\n"
]
},
{
"data": {
"text/plain": [
"<keras.callbacks.History at 0x7f697dc77ac8>"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.fit(X_train,Y_train, validation_data=(X_test,Y_test),epochs = 10, batch_size = 50, verbose = 2)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"accuracy = model.evaluate(X_test, Y_test, verbose=0)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"accuracy is 97.95\n"
]
}
],
"source": [
"print(\"accuracy is %0.2f\" % (accuracy[-1]*100)) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
95 changes: 95 additions & 0 deletions Phase 1/Python assignment/Top95.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
said 2762
one 2008
prince 1856
pierre 1753
now 1242
natásha 1061
will 1050
man 1031
andrew 1015
time 891
face 885
princess 859
went 857
french 847
eyes 815
know 806
old 801
room 757
thought 752
men 747
chapter 731
began 708
see 703
rostóv 702
go 701
came 680
without 667
moscow 665
asked 664
still 659
looked 646
come 646
well 640
felt 626
count 616
army 615
first 612
left 596
mary 595
another 591
something 589
say 579
seemed 578
two 573
away 572
nicholas 570
life 563
head 558
little 552
day 535
whole 528
hand 527
don’t 515
people 508
even 503
yes 503
long 501
back 497
emperor 495
heard 491
must 480
general 468
way 467
napoleon 462
always 461
saw 461
look 461
made 457
russian 449
nothing 442
young 440
though 435
countess 434
kutúzov 430
suddenly 428
love 426
round 418
knew 407
right 407
voice 407
smile 406
never 405
told 405
officer 402
moment 400
took 395
looking 389
us 389
everything 386
much 385
sónya 385
turned 384
let 375
quite 374
tell 373