The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

How to do Tensorflow image recognition?

MarkBMarkB Member Posts: 1 Learner I
edited March 2021 in Help
I want to load "fashion_mnist" dataset from "tensorflow_datasets" and process it with "Deep Learning" extension.
The original "fashion_mnist" data is (60000,(28,28,1),(1)) so, I converted it to the BATCH/ID Tensor by "Execute Python":

import pandas as pd
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
tfds.disable_progress_bar()
image_size = 28

def normalize_img(row):
    img = row.image.reshape((image_size,image_size))/255.0
    img = np.append(img, [range(image_size)], axis=0)
    img = np.append(img, [np.ones(image_size)*row.name], axis=0)
    img = np.append(img, [np.ones(image_size)*row.label], axis=0)
    row.image = img.T
    return row

def preprocess_df(df):
    df.image = df.apply(normalize_img, axis=1)       
    df = pd.DataFrame(np.dstack(df.image.to_numpy()).transpose(2,0,1).reshape(df.shape[0]*image_size,image_size+3))    
    df.rename(columns={28: 'id', 29:'batch', 30:'label'}, inplace=True)
    return df

def rm_main():
    dataset, metadata = tfds.load('fashion_mnist', shuffle_files=True, as_supervised=True, with_info=True)
    df_train = tfds.as_dataframe(dataset['train'], metadata)
    df_test = tfds.as_dataframe(dataset['test'], metadata)
    df_train = preprocess_df(df_train)
    df_test = preprocess_df(df_test)
    return df_train, df_test
First of all, is it correct format?
If I want to set Batch on 32 or 64. How to reshape the tensor with Rapidminer blocks?
After that I converted it to Tensor, built model with "Deep Learning (Tensor)", receive the warnings:
WARNING: Couldn't update network in epoch x
Finally, when applied it with "Apply Model (Generic)" I receive an error:
Process failed: operator cannot be executed (getColumn() can be called on 2D arrays only). 


Sign In or Register to comment.