Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Transfer learning. You want to build a classifier that detects bicycles in images. In each sample, the input to the classifier is a set of
Transfer learning. You want to build a classifier that detects bicycles in images. In each sample, the input to the classifier is a set of 5 photos of some scene taken at different angles. Each photo is an RGB image of size 128128. The output of the classifier is a single binary value, 0 or 1 , for each sample, indicating if there was a bicycle in any of the five photos in the sample. (a) You want to write the classifier that takes a set of samples x and return a set of predictions yhat. What should the shape of x and yhat be? (b) You are given an excellent pre-trained image classifier that works on a single 128128 RGB image. The pre-trained classifier was trained on 1000 image classes and can be accessed by: Z=pretrained.predict(X)#Outputsthelogitsforthe1000classes Suppose that in the pre-trained classifier, bicycles were one of the image classes, say class 50. Write a possible implementation of a classifier using the pretrained model: def classify(X, pretrained): return yhat There is no single correct answer. Do something reasonable with an explanation. (c) Now suppose that bicycles were not one of the image classes that the pretrained classifier uses. So, you decide to transfer learn using the outputs of one of the layers near the end of the pre-trained model using simple logistic regression on those outputs. Assume you have the following functions: \# Outputs the 2000 hidden units at some layer near the \# end of the pre-trained model Z = pretrain_base.predict (X) reg = LogisticRegression() \# Builds a logistic regression object reg.fit(X,y) \# Fits the logistic model from X to y yhat = reg.predict (X)# Predicts binary outputs Write functions to fit and predict the pre-trained model: def fit(Xtr,ytr,..) .. return ... defpredict(X,) . . return yhat The functions should take whatever inputs and outputs are necessary
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started