Posts

Showing posts with the label keras

LSTM neural network for multiple steps time series prediction

LSTM neural network for multiple steps time series prediction I tried to develop a model that foresees two time-steps forward In this regard I modified a GitHub code for the single step forecast coding a data_load function that takes n steps backward in the X_train/test series and set it against a y_train/test 2-array. data_load n steps X_train/test y_train/test I set the neurons list to output in Dense a 2-vector object. And last I wrote a predict function and a plot function for the 2-step-forecast. I do not normalized features lables and forecasts I will do in the future. After a bit of hyperfine tuning it returns a good score for the mse and rmse: Train Score: 0.00000 MSE (0.00 RMSE) Test Score: 0.00153 MSE (0.04 RMSE) It can find quite well the trend, but it returns all forecasts with negative directions. Does anyone have a suggestion? import seaborn as sns import numpy as np import matplotlib.pyplot as plt import matplotlib.pyplot as plt2 import pandas as pd from pandas imp...

why keras model param values change when it is accessed in a tensorflow session?

why keras model param values change when it is accessed in a tensorflow session? I was having trouble with my transfer learning implementation. I guess I found the root cause but it is not clear to me why it works like that. Here is the explanation... If I create a model (e.g. resnet50 from keras.applications), and then try to use it in a tensorflow session, weights all of a sudden change. Here is a simple example: First import the necessary libraries: import tensorflow as tf from keras.applications.resnet50 import ResNet50 from keras.models import Model Then define the model as following: model = ResNet50(weights='imagenet') Now print out parameters from one of the layers as following: model.get_layer('conv1').get_weights() The output is long but it starts as following: [array([[[[ 2.82526277e-02, -1.18737184e-02, 1.51488732e-03, ..., -1.07003953e-02, -5.27982824e-02, -1.36667420e-03], [ 5.86827798e-03, 5.04415408e-02, 3.46324709e-03, ..., ...

How to build a Language model using LSTM that assigns probability of occurence for a given sentence

How to build a Language model using LSTM that assigns probability of occurence for a given sentence Currently, I am using Trigram to do this. It assigns the probability of occurrence for a given sentence. But Its limited to the only context of 2 words. But LSTM's can do more. So how to build an LSTM Model that assigns the probability of occurrence for a given sentence? This question has not received enough attention. (TensorFlow Implementation)[tensorflow.org/versions/master/tutorials/… Can some body provide keras implementation? – Shashi Tunga yesterday 1 Answer 1 I have just coded a very simple example showing how one might compute the probability of occurrence of a sentence with a LSTM model. The full code can be found here. Suppose we want to pre...