<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 MNIST with transfer learning.
First let us build a MNIST logistic regression classifier.
We will then get better feature embeddings for images by using dvd library. This involves transfer learning. 
We will compare simple classifier with transfer learnt model for accuracy score.
Step1:  Simple logistic Regression
Step2:  Lets get VGG embeddings for train and test input images and convert them to transfer learnt space.
Step3:  Model with transfer learnt features
<ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=False)
img = mnist.train.images[123]
img = np.reshape(img,(28,28))
plt.imshow(img, cmap = 'gray')
plt.show()
img = np.reshape(img,(28,28,1))
print img.shape, 'label = ', mnist.train.labels[123]
from dvd import dvd
img_embedding = dvd.get_embedding_x(img)
print img_embedding.shape
Explanation: MNIST with transfer learning.
First let us build a MNIST logistic regression classifier.
We will then get better feature embeddings for images by using dvd library. This involves transfer learning. 
We will compare simple classifier with transfer learnt model for accuracy score.
End of explanation
from sklearn import linear_model
from sklearn.metrics import accuracy_score
    
clf = linear_model.LogisticRegression()
clf.fit(mnist.train.images, mnist.train.labels)
preds = clf.predict(mnist.test.images)
print accuracy_score(preds, mnist.test.labels)
Explanation: Simple logistic Regression
End of explanation
train = np.reshape(mnist.train.images, (mnist.train.images.shape[0],28,28))
print 'initial training shape = ', train.shape
train = dvd.get_embedding_X(train)
print 'training shape after embedding =', train.shape
test = np.reshape(mnist.test.images, (mnist.test.images.shape[0],28,28))
test = dvd.get_embedding_X(test)
Explanation: Lets get VGG embeddings for train and test input images and convert them to transfer learnt space.
End of explanation
from sklearn import linear_model
from sklearn.metrics import accuracy_score
clf = linear_model.LogisticRegression()
clf.fit(train, mnist.train.labels)
preds = clf.predict(test)
print accuracy_score(preds, mnist.test.labels)
Explanation: Model with transfer learnt features
End of explanation
<END_TASK>