Keras fit_generator(), is this the correct usage?

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


So far I have come up with this hacky code here, this code runs and outputs

Epoch com/tag/1">10/com/tag/1">10
       com/tag/1">1/3000 [..............................] - ETA: 27s - loss: 0.3075 - acc: 0.7270
       6/3000 [..............................] - ETA: 54s - loss: 0.3075 - acc: 0.7355
.....
    2996/3000 [============================>.] - ETA: 0s - loss: 0.3076 - acc: 0.7337
    2998/3000 [============================>.] - ETA: 0s - loss: 0.3076 - acc: 0.7337
    3000/3000 [==============================] - 59s - loss: 0.3076 - acc: 0.7337    
    Traceback (most recent call last):
      File "C:/Users/Def/PycharmProjects/KerasUkExpenditure/TweetParsing.py", com/tag/line">line com/tag/1">140, in <module>
        (loss, acc) = model.fit_generator(generator(tokenizer=t, startIndex=startIndex,batchSize=amountOfData),
    TypeError: 'History' object is not iterable

    Process finished with exit code com/tag/1">1

I'm confused by "'History' object is not iterable", what does this mean?

This is the first time I've tried to do batch training and testing and I'm not sure i've implemented it correctly as most the examples I've seen oncom/tag/line">line are for images. Here is the code

from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.preprocessing.text import Tokenizer
import numpy as np
import pandas as pd
import pickle
import matplotlib.pyplot as plt

import re

"""
amount of samples out to the com/tag/1">1 million to use, my 960m 2GB can only handel
about 30,000ish at the moment depending on the amount of neurons in the
deep layer and the amount fo layers.
"""
maxSamples = 3000

#Load the CSV and get the correct columns
data = pd.read_csv("C:\\Users\\Def\\Desktop\\Sentiment Analysis Datasetcom/tag/1">1.csv")
dataX = pd.DataFrame()
dataY = pd.DataFrame()
dataY[['Sentiment']] = data[['Sentiment']]
dataX[['SentimentText']] = data[['SentimentText']]

dataY = dataY.iloc[0:maxSamples
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.