New answers tagged

0

The output of an LSTM is of the shape $[?,t,d]$ where $t$ is the number of timesteps and $d$ is the hidden dimension and there are $t$ number of cells in the LSTM - unless "return_sequences" is set to false in Keras. When "return_sequences" is false, the output is $[?,d]$ because it is returning the final timestep of what the output would ...


1

As you are in search of exploding / vanishing gradients, it would be the best to check the gradient histogram, rather than the weights directly. I found a code on Quora, pasting it just in case the link is gone with tf.name_scope('train'): optimizer = tf.train.AdamOptimizer() # Get the gradient pairs (Tensor, Variable) grads = optimizer.compute_gradients(...


0

The problem was I didn't one-hot encode my labels, so my model did not train correctly. I.E I've given my model the label [4] instead of [0,0,0,0,1,0,0] (because there are 7 classes and the label is the fifth) I found out when I switched from using a generator to numpy array, then tensorflow prompt me with an error. I don't understand why didn't tensorflow ...


0

One possibility is that DNNRegressor is a TensorFlow Estimator. TensorFlow Estimators have been deprecated because they "can behave unexpectedly". It might be better to explicitly define a model.


2

In case you have labeled data (previous complaints labeled by humans), you can implement a standard binary text classification model. A rather simple approach would be to encode the text e.g. as TFIDF or "one hot" and run a simple classification task to learn of some text belongs to label "referred" or "not referred" (which ...


0

What you are looking for is a so-called sentiment-analysis in NLP. In this article, you will find an instruction on how to train a Convolutional Neural Network with a BERT Encoder for a sentiment-analysis. You could use this example and just replace the training data with movie reviews (positive / negative) with some of your labeled data. Definitely worth a ...


1

This is quite easy to do using the keras functional API. Assuming you have an image of size 28 by 28 and 5 additional features, your model could look something like this: from tensorflow.keras import Model, Input from tensorflow.keras.layers import Conv2D, MaxPool2D, Dense, Flatten, concatenate input_image = Input(shape=(28, 28, 3)) input_features = Input(...


2

Based on how the EarlyStopping callback is implemented there doesn't seem to be way to accomplish this. After an epoch ends (in your case more specifically the end of the first epoch) it checks if the value at the end of the epoch is an improvement over the current value (see this function, where the current value is stored in self.best. When the training of ...


1

It is crucial to measure the final result reached with prepropressing as best as possible. Therefore, there is a lot of different options depending on the datasets and depending on the algorithms/models. For instance, some models needs data normalization, some models needs logarithm or other transformation to improve the final results. Sometimes, you can ...


0

Given your data is sparse it may be worth trying a loss function for that type of representation. As an example Keras has a SparseCategoricalCrossentropy class: tf.keras.losses.SparseCategoricalCrossentropy( from_logits=False, reduction="auto", name="sparse_categorical_crossentropy" ) More information on this is available here. ...


1

I think the issue is mostly with your network architecture. You are using only one convolutional layers and you are using all sigmoid activiations. Adding more convolutional layers, changing the activations from sigmoid to relu, and changing the optimizer to Adam gives me a loss below 5 after 30 epochs: model = tf.keras.Sequential([ tf.keras.layers.Conv2D(...


9

The procedure that you can use is the following. First cluster your data with gaussian mixture models. This method should also work with multiple lines with different slopes. It should be able to deal with intersections as points near an intersection can belong to both clusters and a wrong classification will not lead to huge differences in the results of ...


1

You can convert any subclass of tf.data.Dataset into numpy via: tfds.as_numpy() According to knowyourdata, the sizes of images vary. So in the format_data() function, you can simply use tf.image.resize() or tf.image.resize_with_pad() (if you want to avoid distortion) to resize it to a fix dimension(300x300). I'm having trouble loading the data on colab so ...


3

There are at least two reasons why the split should be made first: In theory at least, there is a true distribution of the data for the target task. Any model should always be evaluated on the true distribution of the data, because the goal is to predict on this distribution. Since data augmentation modifies this distribution, it's as if the model is ...


0

You might not be building your model correctly. Here is an alternative way to build a model: from tensorflow.keras.models import Sequential layers =[ spectrogram = Input(shape=(time_steps, feature_size)) layer0 = Reshape((time_steps, feature_size, 1)) layer1 = Conv2D(32, kernel_size=(3,3), padding='same') layer2 = MaxPooling2D(pool_size=(4,4)) layer3 = ...


0

So this is a very old question, but for anyone coming from Google: According to the documentation provided by Tensor Flow, tf.estimator.DNNClassifier has the parameter activation_fn which is described by: Activation function applied to each layer. If None, will use tf.nn.relu Therefore, this model only takes one activation function and uses it on all layers. ...


0

The issue is that the model expects images of 416 by 416 pixels, whereas you are using larger images. Simply using reshape doesn't work since the overall number of pixels is still to high for a 416x416 image (720 * 1280 > 416 * 416). Therefore you have to resize your image first to 416x416 before passing it to your model. You can either directly resize to ...


Top 50 recent answers are included