i have following code : %% import pandas as pd import numpy as np from tensorflow import…
- User
i have following code :
%%
import pandas as pd import numpy as np from tensorflow import keras from sklearn.preprocessing import StandardScaler
def data_generator(file_path, batch_size): chunksize = batch_size while True: # Loop forever, so the generator never terminates for chunk in pd.read_csv(file_path, chunksize=chunksize): # Assuming your CSV has headers that match features/targets # Normalizing the features filtered_c = chunk.drop(['Date', 'Symbol'], axis=1)
feature_data = filtered_c.drop([ 'y_High_1d', 'y_Low_1d', 'y_Priority_1d', 'y_High_2d', 'y_Low_2d', 'y_Priority_2d', 'y_High_3d', 'y_Low_3d', 'y_Priority_3d', 'y_High_5d', 'y_Low_5d', 'y_Priority_5d'], axis=1) target_data = filtered_c[['y_High_1d' , 'y_Low_1d', 'y_Priority_1d', 'y_High_2d', 'y_Low_2d', 'y_Priority_2d', 'y_High_3d', 'y_Low_3d', 'y_Priority_3d', 'y_High_5d', 'y_Low_5d', 'y_Priority_5d' ]] scaler = StandardScaler() feature_data_scaled = pd.DataFrame(scaler.fit_transform(feature_data), columns=feature_data.columns) # Assuming target_data also needs to be scaled, apply scaler separately target_data_scaled = pd.DataFrame(scaler.fit_transform(target_data), columns=target_data.columns) # Now, feature_data_scaled and target_data_scaled are both DataFrames, scaled and ready to use yield feature_data_scaled.values, target_data_scaled.values%%
from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Input import tensorflow as tf
def build_model(): input_shape = (6427,)
model = Sequential([ Dense(6427, activation='relu', input_shape = input_shape), Dropout(0.25), Dense(3200, activation='relu'), Dropout(0.20), Dense(1800, activation='relu'), Dropout(0.15), Dense(1024, activation='relu'), Dropout(0.10), Dense(512, activation='relu'), Dropout(0.05), Dense(256, activation='relu'), Dense(128, activation='relu'), Dense(64, activation='relu'), Dense(32, activation='relu'), Dense(12), ]) model.compile(optimizer='adam', loss='mse', # Use Mean Squared Error for regression metrics=['mae']) # Mean Absolute Error as an additional metric return model%%
file_path = r"C:\Users\arisa\Desktop\combined_day.csv" batch_size = 128
Instantiate the model
model = build_model()
model.summary()
%%
Setup the data generator
train_generator = data_generator(file_path,batch_size)
Assuming you know or calculate the total number of rows in advance
total_samples = 1000000 # Example number, replace with your dataset's size steps_per_epoch = total_samples // batch_size
Train the model
- Assistant
- User
also my gpu is 3070 how can i make sure that model train on gpu for faster training
- Assistant
- User
im ggeting following message
- Assistant
It seems like your message got cut off before you could provide the specific details about the message you're receiving. Could you please share more about the message or error you're encountering? This information will help me provide you with more targeted assistance.
For example, if TensorFlow is displaying a warning or error message regarding GPU usage, CUDA, cuDNN versions, or if it's a message about memory allocation, sharing the exact text or error code would be incredibly helpful to diagnose the issue and suggest solutions.
- User
this message: Please install GPU version of TF
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.