🎉 🎉 RAPIDMINER 9.10 IS OUT!!! 🎉🎉

Download the latest version helping analytics teams accelerate time-to-value for streaming and IIOT use cases.


How to do Tensorflow image recognition?

MarkBMarkB Member Posts: 1 Newbie
edited March 24 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
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.