Multiple issues and errors with tensor flow array / matrix / tensor shape and data manipulation

import tensorflow as tf
import numpy as np
from tqdm import tqdm
from datasets import load_dataset
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras import layers, Input
import random
from datetime import datetime, timedelta
from datasets import load_dataset

from datasets import load_dataset
dataset = load_dataset("csv", data_files="bitcoin_daily/data_btc.csv", split="train")

input_shape = (3, 6)

def GetRandomThirtyDays(dataset):
    
    dates = dataset["date"]
    random_date = random.choice(dates)
    
    # Find the index of the random date
    random_date_index = dates.index(random_date)
    
    # Get the last 30 days starting from the random date
    start_index = max(0, random_date_index - 5)  # Ensure the start index is not negative
    last_30_days_dates = dates[start_index:random_date_index]  
    
    # Check if all dates exist in the dataset
    for date in last_30_days_dates:
        if date not in dates:
            return GetRandomThirtyDays()  # If any date is missing, recursively call the function to get a new random set of 30 days
    
    # Save the indices of the last 30 days
    last_30_days_indices = list(range(start_index, random_date_index + 1))
    
    return  last_30_days_indices, random_date_index + 1
def VerifyIndexExists(dataset, index):
    try:
        dataset["price"][index]
        return dataset["price"][index]
    except:
        return False
def GetSellPrices(dataset, indices, ):
    # Get the sell prices for the last 30 days using the indices
    DataDictionary = []
    Destroyed = False
    for index in indices:
        # Get the sell price, market_caps and the volumes for the current index IF it exists and return it. If anything is nil (destroyed)

        try:
            if dataset["price"][index] == None:
                Destroyed = True
                break
            sell_price = dataset["price"][index]
            if dataset["market_caps"][index] == None:
                Destroyed = True
                break
            market_cap = dataset["market_caps"][index]
            if dataset["total_volumes"][index] == None:
                Destroyed = True
                break
            volume = dataset["total_volumes"][index]
            DataDictionary.append([sell_price, market_cap, volume])
        except:
            Destroyed = True
    
    return DataDictionary, Destroyed

def Get30DayData(dataset):
    indices, answerIndex = GetRandomThirtyDays(dataset) #Get 30 random dates   
    ThirtyDayDataDictionary, Destroyed = GetSellPrices(dataset, indices)
    # go back recursively if we are destroyed
    PredictionAnswer = VerifyIndexExists(dataset, answerIndex)
    if not PredictionAnswer:
        return Get30DayData(dataset)
    if Destroyed:
        return Get30DayData(dataset)
    return ThirtyDayDataDictionary, PredictionAnswer


model = tf.keras.Sequential([
    layers.Input(shape=input_shape),  # Input layer with specified shape
    layers.Flatten(),
    layers.Dense(64, activation='relu'),
    layers.Dense(10, activation='softmax'),
    layers.Dense(1, activation='sigmoid')
])

model.compile(optimizer="adam", loss="mean_squared_error", metrics=["accuracy"])

X_training = []
answer = []
for _ in tqdm(range(20)):
    X, y = Get30DayData(dataset)
    if X:
        X_training.append(X)
        answer.append(y)

X_training_np = np.array(X_training)
answer = np.array(X_training)
   
model.fit(X_training_np, answer, epochs=300, batch_size=1, verbose=0)
model.evaluate(X_training_np, answer, verbose=2)

This is my code and I’m getting multiple random shape errors. I am a tensorflow beginner. The reason Im only using the past 5 days of data is because it’s easier to read as a log. Help would be appreciated!

Im trying to train an ANN on a 3 by 5 list to capture all the data of the past days using a float as the prediction.

New contributor

Dylan Bates is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật