kratzert.github.io | blogI wrote a blog post describing | Blog library
kandi X-RAY | kratzert.github.io Summary
kandi X-RAY | kratzert.github.io Summary
my blog
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kratzert.github.io
kratzert.github.io Key Features
kratzert.github.io Examples and Code Snippets
Community Discussions
Trending Discussions on kratzert.github.io
QUESTION
I am trying to perform pixel by pixel operations on the image but it is painfully slow. It is taking 7-8 hours for a single image of dimension(512*512) and I have images upto 2048*2048.
I have also tried it optimising using Numba but it is taking the same time due to the presence of plenty of pyobjects
which is according to this tutorial is bad as numba is not able to translate the variables into something it understands and hence optimise.
Below is the short version of my question, I have enclosed the complete details So, now I am trying to use cython by following this tutorial. Following is my code, which I am trying to optimise-
...ANSWER
Answered 2019-Oct-17 at 17:54I would definitely look into using scikit-image or at least using numpy for anything where you need to process pixels in an image. It will take way too long in pure python.
To reproduce your first bit of code with skimage, I would do this:
QUESTION
I am using an AlexNet from here
The data there has 1000 classes so it has weights according to that. How do I make it work for predicting values for my data that has 3 classes?
I know I have to change the weights but I don't know how.
...ANSWER
Answered 2018-Apr-28 at 16:16You just have to set num_classes = 3
which will reduce the number of output classes for both the model output tensor and the separately defined placeholder y
.
The number of weights, i.e. parameters, will be adapted accordingly when calling model = AlexNet(...
.
QUESTION
Given the input values [1, 5]
and normalizing them, should yield something like [-1, 1]
if I understand correctly, because
ANSWER
Answered 2017-Sep-27 at 09:37If you're using gamma
, the right equation is actually result = gamma * (x - mean) / sqrt(var)
for batch normalization, BUT mean
and var
are not always the same:
During training (fit), they are
mean_batch
andvar_batch
calculated using the input values of the batch (they are just the mean and variance of your batch)), just as you're doing. In the meanwhile, a globalmoving_mean
andmoving_variance
are learnt this way:moving_mean = alpha * moving_mean + (1-alpha) * mean_batch
, with alpha is a kind of learning rate, in (0,1), usually above 0.9.moving_mean
andmoving_variance
are approximations of the real mean and variance of all your training data.Gamma
is also learnt, by usual gradient descent, to best fit your output.During inference (predict), you just use the learnt values of
moving_mean
andmoving_variance
, not at allmean_batch
andvar_batch
. You also use the learntgamma
.
So 0.05885344
is just an approximation of the mean of your random input data, 0.91000736
of its variance, and you're using these to normalize your new data [1, 5]. You can easily chack check that [0.79519051, 4.17485714]=gamma * ([1, 5] - moving_mean)/sqrt(moving_var)
edit: alpha
is called momentum in keras, if you want to check it.
QUESTION
I'm trying to execute a prediction on a model that I trained using "Finetuning AlexNet with TensorFlow" https://kratzert.github.io/2017/02/24/finetuning-alexnet-with-tensorflow.html
I saved the model using tf.saved_model.builder.SavedModelBuilder
in Python, and loaded the model in Java using SavedModelBundle.load
.
the main part of the code is:
ANSWER
Answered 2017-Jun-22 at 14:38From the error message, it appears that the model you're using expects to be fed another value (whose node name in the graph is Placeholder_1
and the expected type is a float scalar tensor).
It seems you've customized your model (as opposed to following the article you linked to verbatim). That said, the article shows multiple placeholders that need to be fed, one for the image and another to control dropout. Defined in the article as:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kratzert.github.io
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page