machine-learning
How to recognize rectangles in this image?
Opencv (image processing and computer vision library written in c) has implementation for hough transform (the simple hough transform find lines in an image, while the generalized one finds more complex objects) so that could be a good start. For the rectangles which do have closed corners there are also corner detectors such as cornerHarris … Read more
What are the differences between all these cross-entropy losses in Keras and TensorFlow?
There is just one cross (Shannon) entropy defined as: H(P||Q) = – SUM_i P(X=i) log Q(X=i) In machine learning usage, P is the actual (ground truth) distribution, and Q is the predicted distribution. All the functions you listed are just helper functions which accepts different ways to represent P and Q. There are basically 3 … Read more
How would one use Kernel Density Estimation as a 1D clustering method in scikit learn?
Write code yourself. Then it fits your problem best! Boilerplate: Never assume code you download from the net to be correct or optimal… make sure to fully understand it before using it. %matplotlib inline from numpy import array, linspace from sklearn.neighbors import KernelDensity from matplotlib.pyplot import plot a = array([10,11,9,23,21,11,45,20,11,12]).reshape(-1, 1) kde = KernelDensity(kernel=”gaussian”, bandwidth=3).fit(a) … Read more
How to run Flask with Gunicorn in multithreaded mode
You can start your app with multiple workers or async workers with Gunicorn. Flask server.py from flask import Flask app = Flask(__name__) @app.route(“https://stackoverflow.com/”) def hello(): return “Hello World!” if __name__ == “__main__”: app.run() Gunicorn with gevent async worker gunicorn server:app -k gevent –worker-connections 1000 Gunicorn 1 worker 12 threads: gunicorn server:app -w 1 –threads 12 … Read more
Keras Text Preprocessing – Saving Tokenizer object to file for scoring
The most common way is to use either pickle or joblib. Here you have an example on how to use pickle in order to save Tokenizer: import pickle # saving with open(‘tokenizer.pickle’, ‘wb’) as handle: pickle.dump(tokenizer, handle, protocol=pickle.HIGHEST_PROTOCOL) # loading with open(‘tokenizer.pickle’, ‘rb’) as handle: tokenizer = pickle.load(handle)
Perceptron learning algorithm not converging to 0
In your current code, the perceptron successfully learns the direction of the decision boundary BUT is unable to translate it. y y ^ ^ | – + \\ + | – \\ + + | – +\\ + + | – \\ + + + | – – \\ + | – – \\ + … Read more
What is the difference between loss function and metric in Keras? [duplicate]
The loss function is used to optimize your model. This is the function that will get minimized by the optimizer. A metric is used to judge the performance of your model. This is only for you to look at and has nothing to do with the optimization process.
Why does one hot encoding improve machine learning performance? [closed]
Many learning algorithms either learn a single weight per feature, or they use distances between samples. The former is the case for linear models such as logistic regression, which are easy to explain. Suppose you have a dataset having only a single categorical feature “nationality”, with values “UK”, “French” and “US”. Assume, without loss of … Read more
Cost function training target versus accuracy desired goal
How can we train a neural network so that it ends up maximizing classification accuracy? I’m asking for a way to get a continuous proxy function that’s closer to the accuracy To start with, the loss function used today for classification tasks in (deep) neural nets was not invented with them, but it goes back … Read more