Posts

Showing posts with the label Deep learning

LSTM-Demo: Bidirectional LSTM with TensorFlow on the Sonar Dataset

Image
LSTM-Demo is a compact, runnable example that trains a bidirectional Long Short-Term Memory (LSTM) network with TensorFlow and Keras on the classic Sonar dataset. The Sonar dataset is a well-known binary classification benchmark: each sample has 60 numeric features from sonar returns, and the task is to tell metal cylinders (mines) from rocks. It is small enough to train quickly while still showing a full pipeline. A bidirectional LSTM reads the input sequence in both directions, which can help the model use context from the whole sequence. The demo is intended as a teaching example you can run, read, and modify. It is archived on Zenodo with a citable DOI. DOI: https://doi.org/10.5281/zenodo.20672929

[SOLVED] Tuple index out of range in TensorFlow model fit function

Image
model.fit(): list vs NumPy array # Problem: plain Python lists model.fit(x_train, y_train) IndexError: tuple index out of range # Fix: wrap with np.array() model.fit(np.array(x_train), np.array(y_train)) training runs When training a Keras or TensorFlow model you may hit an IndexError: tuple index out of range the moment you call model.fit() , even though your data looks fine. The cause is almost always the type of the data you passed in, not the model. This post explains why it happens and the one-line fix. The problem code Here training data is built up as plain Python lists and passed straight to fit : x_train = [] y_train = [] # ... append samples to the lists ... history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs) This raises: IndexError: tuple index out of range Why it happens Keras needs to know the shape of your input to wire up the first layer and to split data into batches. It reads that shape from the .shape attribute of the a...

[How To] Run Bidirectional LSTM in Python

Image
 This is a sample program to run bidirectional LSTM in Python using Tensorflow. The complete code repository is available at  https://github.com/devharsh/LSTM-Demo . Code: #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 1 13:34:00 2022. @author: devharsh """ import matplotlib.pyplot as plt from pandas import read_csv from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder from tensorflow import keras from tensorflow.keras import layers inputs = keras.Input(shape=(None,), dtype="float64") xem = layers.Embedding(101, 128)(inputs) xl1 = layers.Bidirectional(layers.LSTM(64, return_sequences=True))(xem) xl2 = layers.Bidirectional(layers.LSTM(64))(xl1) outputs = layers.Dense(1, activation="sigmoid")(xl2) model = keras.Model(inputs, outputs) model.summary()

NVIDIA Deep Learning Webinar

Image
DEEP LEARNING LAB SERIES SCHEDULE: [Click the respective link to open the folder] 7/22 Class #1 - Introduction to Deep Learning 7/29 Office Hours for Class #1 8/5 Class #2 - Getting Started with DIGITS interactive training system for image classification 8/12 Office Hours for Class #2 8/19 Class #3 - Getting Started with the Caffe Framework 8/26 Office Hours for Class #3 9/2 Class #4 - Getting Started with the Theano Framework 9/9 Office Hours for Class #4 9/16 Class #5 - Getting Started with the Torch Framework 9/23 Office Hours for Class #5 It is an introductory course (free online webinar) on Deep learning which is a part of Machine learning which is a part of Artificial intelligence. More information available at developer.nvidia.com/deep-learning-courses Useful links: Caffe: http://caffe.berkeleyvision.org/ Theano: http://deeplearning.net/software/theano/ Torch: http://torch.ch/ DIGITS: https://developer.nvid...