A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

0

Pass a dictionary in the following format to class_weight parameter in fit_generator: { 'output1': {0: ratio_1 , 1: ratio_2} , 'output2': {0: ratio_3 , 1: ratio_4}} You can use class_weight from sklearn.utils to calculate class weights from your data References: https://github.com/keras-team/keras/issues/4735#issuecomment-267473722 https://scikit-learn....


1

More or Less this would be helpful Link: Extracting information from documents Approach & Algorithm from the above blog Approach The algorithm looks for phrases that look like a date. Then it picks the one which appears in the highest position in the document. In the corpus we used, almost every date contained the month written as a word (e.g. April),...


0

I have a similar use-case and a working product based on tensorflow object-detection api and pytesseract for OCR. On top of the extracted text, I perform regex for validation of the extracted information and cleaning it to meet requirements of other processes. Steps: 1. Annotate images with some tool like labelimg. I annotated a set of 1K images, similar ...


0

In Keras, with verbose=1 (default parameter of the fit method) will display the total number of samples, not the batch number. If your batch size is 128, then the progress bar will jump by multiples of 128. You can try to change batch_size parameter to 13714, and you will see the progress bar jumping straight from 0/13714 to 13714/13714, since you would ...


0

A completely different answer: I am currently following a course Computer Vision and Image Analysis: https://courses.edx.org/courses/course-v1:Microsoft+DEV290x+1T2020/course/ With your problem in mind you could follow along. Depending on previous knowledge you could skip a few sections. (I skipped immediately to Beyond Classification/Object Detection) ...


0

I would suggest that you should use a pre-trained OCR model and train your own custom model which only outputs required data. Training method: Just use a pre-trained OCR model like this, and remove the tail of the model and add your custom output layer with the required number of fields (in your it's case invoice and date). After this, freeze the head of ...


1

To answer your questions in order: The whole point of LSTM (or any time series model) is to predict previously unseen values. If states are not reset - then there is a risk of data leakage - whereby forecasts from the training set will lead into the test set. This would mean that your model would perform quite well on the existing set of data - but would ...


0

If you really just want to guess the sign, you should just build a new target : 0 if the sign is negative 1 if the sign is positive... That would fit with your binary classification approach and the metrics you want to use.


1

There are some commands you must run, designed specifically for Colab: from google.colab import drive drive.mount('/content/drive') With this, an authentication page will open. They want you to explicitly allow an access to your Drive. Click on the link and get a key code, that you can insert into an input line. At that point, you Colab Notebook is ready ...


0

If you label your data using -1 and 1 as classes, then yes you can. However, there are two reasons why data scientists normally prefer Sigmoid activations: Loss functions, such as cross entropy based, are designed for data in the [0, 1] interval. Better interpretability: data in [0, 1] can be thought as probabilities of belonging to acertain class, or as a ...


4

Simple explanation with images We know that an activation is required between matrix multiplications to afford a neural network the ability to model non-linear processes. A classical LSTM cell already contains quite a few non-linearities: three sigmoid functions and one hyperbolic tangent (tanh) function, here shown in a sequential chain of repeating (...


0

Your MAE_val is: MAE_val= np.mean(np.absolute(y_val - pred_val )) On the other side, you fit your model on: history = model.fit(x_train, y_train, ... So you are calculating them on different objects. Training data on one side, and validation set for a final evaluation.


0

I created a rule to achieve reproducibility: Works for python 3.6, not 3.7 First install Keras 2.2.4 After install tensorflow 1.9 And finally in the code: import numpy as np import random as rn import tensorflow as tf import keras from keras import backend as K #-----------------------------Keras reproducible------------------# SEED = 1234 tf....


1

I think you already have some OCR in place? I don't know if you also have the x-y locations and size of the recognized texts? I hope you have a model that knows (has learned) occurrences of 'invoice #' as a label. And maybe you can machine learn to recognize values that could be invoice numbers. 2034, 200.00 could be invoice numbers, 'Date' and 'Service ...


0

This tutorial explains in a nice and simple way how to create a data generator which you can pass to your Keras model to train using fit_generator(). Two things to keep in mind about Keras generators, in order to be compatible with Tensorflow 2.x requirements: Your generator should inherit from keras.utils.Sequence, which allows for internal parallelization ...


1

I got it. You define a new model, which has an input, the shared embedding layer and a flattened output. Pass the output of .predict() from that model to y parameter of your main model's .fit() call, in like fashion: NUMERIC_FEATURES = [ # Define the subset of features that need passing to the numeric input layer ] vocab_size = 10000 # number of items ...


0

First you need to define a function using backend functions. As an example, here is how I implemented the swish activation function: from keras import backend as K def swish(x, beta=1.0): return x * K.sigmoid(beta * x) This allows you to add the activation function to your model like this: model.add(Conv2D(64, (3, 3))) model.add(Activation(swish)) ...


0

The log data is forward propagation loss,still have a backward modify. If use model train one time,you will get the data you wanted.


0

I was looking your hyper-parameters, seems ok, maybe the min epsilon is to high but don't think this is the problem. Your reward scheme is not the best. Going towards the food twice is the same as eating the food on time, so the return of a policy will vary a lot depending on how far is the food. In other words and only as an example, is better to go towards ...


2

Weighting MSE is a way to give more importance to some prediction errors than to others in the overall score. This is useful if you are using MSE as a performance metric for your model, especially during the model training (loss function) or validation (hyper-parameter setting). In the case you cite as example, more importance is given to cases with more ...


1

I have not used PELU activation function by myself, so dont know much about its performance benefits but can say a, b, and c looks to be hyperparameters only. and it can be directly implemented in tensorflow 2.0 as tf.cond(h, lambda:c*h, lambda:a(tf.exp(h/b)-1))


0

This is probably laye but incase someone else is stuck, check out this link. Basically, your model expects two inputs as defined here: model = Model([input1, input2], output_layer) Therefore you will need to pass a list of two inputs with the same shape as you defined here: input1 = Input(shape=(480,480,3)) input2 = Input(shape=(480,480,1))


1

As promised, here you can find an example of how you could apply kfold cross validation for a defined convolutional neural network model, applied to an augmented dataset. You can find the code as a simple gist here It is done as follows: for a subset of the CIFAR10 images dataset, generate 3 augmented images (by applying horizontal_flip) per original image, ...


1

In short, value of model.predict() function is interpreted as mentioned in option 2. In order to clarify, let's assume we are talking about spam detection application. Label 0 represents that text/email is not spam and label 1 represents that text/email is spam. Suppose, after running the function model.predict(), we get value 0.9899. Then we can interpret ...


0

please check this answer and see if it helps . Somehow I feel that you are getting the predict probability rather than the prediction itself https://stackoverflow.com/questions/40002084/how-to-output-a-prediction-in-tensorflow


0

Please find a working solution here. The generators look like: # Data generators train_datagen = ImageDataGenerator( rescale=1./255, rotation_range=40, width_shift_range=0.2, height_shift_range=0.2, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode='nearest') # Note that the validation data ...


0

I somehow feel that the issue rather than being technical is more functional in nature. One should try converting age into bins of age ranges and then use it as a multiclass classification problem statement. Predicting age from a picture is something that even humans fails at so that inherent misintepretation would be "learned" by NN as well and MAE always ...


0

First, what you need to consider is not whether you can or not, but whether your practice so far or what you are planning to do make sense for your use-cases. Basically choose whichever make more sense for your use-cases. After you decide, now for your question, It is very possible. The next thing you want to consider is what loss function to use. Note that ...


0

I am pleased to provide the direct usage of kernel, recurrent_kernel and bias in the following expression. I am wondering the Keras usage is quite rare in the programming language. Shall some one give an exact explaining to the array expression . ### kernel--weights between x_{t} and units W_i = W[:, :units] W_f = W[:, units:units * 2] W_c = W[:, units *...


0

For a start I would begin with simpler tests cases because they look rather complex (see an exemple of what you seems to simulate below). May be start with a 10x10 grid and generate 1 to 5 islands of different size.


1

When implementing a model from a paper to reproduce their results, it is very important to pay attention to all the details. For this case there are some important differences when comparing to the CIFAR10 results of ResNet: You are using the Adam optimizer, while the ResNet paper uses SGD with a learning rate schedule. Adam is known to have issues ...


0

This checkerboard effect arises due to taking sum of the overlapping regions during the transpose-convolution operation. Post convolution, in the output, the overlapping pixels have a higher magnitude than the surrounding pixels. Try using a filter size of 4x4 along with a stride 2 transpose convolution. It may help to alleviate this problem. For more ...


0

I just figured out the same issue. Try to pass a dictionary like: { 0: 1.0, 1: 10, 2: 20, 3: 20, 4: 20 } to class_weight in model.fit() and it will solve the problem. Understood that it says a list will also work in the docs - but seems like it does not work as well for me.


0

Imagine you have a basic maths framework, a lot of functions doing addition, subtraction, multiplication and division. Imagine in everyday life you often need to compute averages. Then you make a function (using the functions from the framework, inside it), that will take an array of numbers as parameters an return the mean. The framework is actually ...


3

Lets go back to basics here. It is not possible to only use Keras without using a backend, such as Tensorflow, because Keras is only an extension for making it easier to read and write machine learning programs. All the actual calculations needed to create models are not implemented in Keras, which is why you need to use a backend library for anything to ...


1

Keras used to use 2 backends(Theano and Tensorflow), but now only supports Tensorflow because of the discontinuation of Theano. The reason why Keras uses Tensorflow as it's backend is because it is an abstraction layer. It is the easiest way to get started with AI and machine learning because all of the core algorithms are implemented in tensorflow and ...


34

This makes more sense when understood in its historical context. These were the chronological events: April 2009 Theano 0.1 is released. It would dominate the deep learning framework scene for many many years. June 2015 Keras is created by François Chollet. The goal was to create an abstraction layer to make Theano easier to use, enabling fast prototyping. ...


1

The first point to note is that Keras can potentially use many backends (e.g. Theano before it was discontinued, Microsoft Cognitive Toolkit, to name a couple). It just so happens that Keras has proven to be the most popular among the community. As a result, TensorFlow has adapted to the extent that Keras is now the default API in TensorFlow 2.0. One of the ...


3

Additionally: Think of it as an abstraction layer. Keras gives nice and intuitive way to build and think about neural network, but you have to understand thats not how computer takes orders. Hiding this complexity behind Tensorflow allows us to think naturally about building a neural network and not all the details behind implementation. (On a general note ...


5

Keras is an application programming interface (API). It is a single interface that can support multi-backends, which means a programmer can write Keras code once and it can be executed in a variety of neural networks frameworks (e.g., TensorFlow, CNTK, or Theano). TensorFlow 2.0 is the suggested backend starting with Keras 2.3.0.


4

Its huge discrepancy, I suspect a lie. While +33% can be achieved, you said that you tried very different architectures and you did not get even close. Dont expect that one tweak, one layer, one xyz can give you all of a suddenly such a huge increase. If you did not get closer using suggestions from the paper there is also a possibility (not saying they did,...


1

I can see you are using "plain" deepQ, consider using double deep Q or duelling, but go first on your current implementation. First of all, most of the times the problem is a bug, can you provide the history of the scores?. It is important to understand if the agent is learning or the best solution it can find is killing itself to minimize loses. As per ...


0

You may need to spend more time identifying the problem than looking for tricks that have worked in literature. So start with the simplest architecture and see how and on what values your network is converging. It's hard to know all the details but here are a few suggestions that might help. You may try different initializations and also random re-...


1

What you could do is make two models. Since, the first class is the most important one, you could first do a binary classification (is it the first class or not), after you finished you train your model with data that wasn't the first class and classify it on 13 labels.


0

Try deeper network. Something like this. self.model = models.Sequential() self.model.add(layers.Dense(self.num_layers, activation="relu", input_shape=(self.x_train.shape[1],))) self.model.add(layers.Dense(self.num_layers//2, activation="relu")) self.model.add(layers.Dense(self.num_layers//4, activation="linear")) self.model.add(layers.Dense(1)) self.model....


1

Normalize to $[0, 1]$ is what I'd do to ensure that the model gets expected (sanitized) inputs. Using the samplewise_std_normalization is something that I'd do inside the model to highlight features. E.g. a white pixel is more important in a mostly black image than in a noisy image.


0

You can use CTPN to localise text and later use OCR for capturing the text , refer to the git page it will serve your purpose .you can pretrain on your custom data set as well.


5

Your information is not discriminative enough Why? Coefficients of polynomials dont give (alteast partially) discriminative information about roots of the polynomial. In other words different coefficients could give same roots. It does not matter how complex your network is it cant catch what is not there to be catched in the first place.


1

Also a couple of things that proved valuable besides mentioned are batch normalisation and feewer deep layers. The less complexity the more generalisation power you can have.


2

Your model is completely overfitting. The training loss is constantly decreasing but the validation loss isn't. This means that the your current model is complex enough to 'memorize' the patterns in the training data. In such situations, you need to regularize your model. To regularize your data you may try any or all combination of the following: 1) ...


Top 50 recent answers are included