Categories
Development

Stuck in the first epoch when training the CNN-LSTM using Keras

I am using Keras to construct a CNN-LSTM model for tweet classification. The model has two inputs and the task is a three-class classification. The code I use to construct the model is given below: def conv2d_lstm_with_author(): # Get the input information – author & tweet author_repre_input = Input(shape=(100,), name=’author_input’) tweet_input = Input(shape=(13, 100, 1), […]

Categories
Development

Incorporating lexical features/knowledge into classifier to Improve Sentiment Classification

I have a script wihich classify my data but the accuracy is not well for one of the classes. I will like to insert a lexicon of words specific of the class so that to improve the classification of that class and eventually the others classes. below my script : datafile = read_excel(filename, sheet_name= my_sheet) […]

Categories
Development

Difference between va_loss from fit and score from evaluate?

I am learning to use tf and Keras with a regression problem. I have written this function for cross-validate differents models, in order to compare them. def cv(X, y, model, n_splits=5, epochs=5, batch_size=1024, random_state=42, verbose=0): # kf = KFold(n_splits=n_splits, shuffle=True, random_state=random_state) kf = KFold(n_splits=n_splits, shuffle=False, random_state=random_state) histories = [] for s in kf.split(X): X_train = […]

Categories
Development

Difference between va_loss from fit and score from evaluate?

I am learning to use tf and Keras with a regression problem. I have written this function for cross-validate differents models, in order to compare them. def cv(X, y, model, n_splits=5, epochs=5, batch_size=1024, random_state=42, verbose=0): # kf = KFold(n_splits=n_splits, shuffle=True, random_state=random_state) kf = KFold(n_splits=n_splits, shuffle=False, random_state=random_state) histories = [] for s in kf.split(X): X_train = […]

Categories
Development

Keras: Performance of model.fit() when shuffle=False or True

In Keras, when we are training a model for a fixed number of epochs using model.fit(), one of its parameters is shuffle (a boolean). The Keras documentation about it reads: “Boolean (whether to shuffle the training data before each epoch).” Essentially, I am training a Convolutional Neural Network and trying to get reproducible results. So, […]

Categories
Development

PyTorch and TensorFlow object detection – evaluate – object of type

I’m attempting to get this PyTorch person detection example running: https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html I’m using Ubuntu 18.04. Here is a summary of the steps I’ve performed: 1) Stock Ubuntu 18.04 install on a Lenovo ThinkPad X1 Extreme Gen 2 with a GTX 1650 GPU. 2) Perform a standard CUDA 10.0 / cuDNN 7.4 install. I’d rather not […]

Categories
Development

Restoring Tensorflow Model without saving

In Tensorflow, I have noticed that if we want to save model we use the tf.Saver function or it’s other counterparts. And when we have to load the model, we use it’s restore counterpart==> # Importing and restoring Meta-graph # Saving the model…. saver = tf.train.import_meta_graph(‘my-save-dir/my-model-10000.meta’) # And Restoring the model… saver.restore(sess, ‘my-save-dir/my-model-10000’ Of every […]

Categories
Development

Tensorflow MultiWorkerMirroredStrategy on SLURM nodes

I’m trying to get MultiWorkerMirroredStrategy working with Tensorflow 2.0, Python 3.7 on SLURM using multiple nodes. For this example, let’s say I have 2 Nodes with 2 GPUs each, although this could scale up to any N number of nodes, but to make it clear for the provided examples. My 2 nodes are Node1 and […]

Categories
Development

2GB limit error when training Keras sequential model using Tensorflow dataset

I’m using tf.data.experimental.make_csv_dataset function to create the input to a Keras sequential model. My first layer is a DenseFeature that receives a list of tf.feature_column (indicator, bucketized, numeric etc). The following layers are Dense using relu activation. When I run the fit function I get the error: “Cannot create a tensor proto whose content is […]

Categories
Development

TF2.0 Invalidargumenterror Inputs to operation AddN of type AddN must have the same size and shape. Input 0: [4,1] != input 1: [] [Op:AddN]

I am new to tensorflow 2.0. I am trying to build a neural network with some additional theoretical information. Basically, the idea is to combine multiple neural networks and in between add some theoretical information. In the below code snippet, I replicated the error with boston housing dataset. I am getting an error while computing […]