Enum instead of String for tensor layout

Skip to first unread message

Zoran Sevarac

Jan 20, 2021, 9:06:19 AM1/20/21
to j...@tensorflow.org

I see dataFormat(String dataFormat) for Tensor Layout format on many places like in

Could we use enum instead of String, since it seems to me that in original c and cudnn api this is enum?
Something like
enum TensorFormat {
      NHCW, NHWC;
Maybe also add NCHW_VECT_C if it makes sense

Zoran Sevarac, PhD, Associate Professor
University of Belgrade, Faculty of Organisational Sciences, Department for Software Engineering
Java Champion | Oracle Groundbreaker Ambassador | Deep Netts Co-founder & CEO

Jim Clarke

Jan 20, 2021, 11:45:51 AM1/20/21
to Zoran Sevarac, j...@tensorflow.org

In Losses.java I have:

public static final int CHANNELS_LAST = -1;
public static final int CHANNELS_FIRST = 1;

I believe it is the same concept. It’s used in metrics.CategoricalCrossentropy and losses.CategoricalCrossentropy
 Losses.categoricalCrossentropy() as the axis value:

•  axis=-1 corresponds to data format `Channels Last’
•  axis=1 corresponds to data format 'Channels First’.

The axis value is passed to nn,softmaxCrossEntropyWithLogits

If you create an enum I’ll change the  CategoricalCrossentropy related classes to use it.

You received this message because you are subscribed to the Google Groups "SIG JVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jvm+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/jvm/CAJHj7Cc-4S78Tgz6Tyxm4BmXcAv_JffxLe3emR31w6QuFGWmvw%40mail.gmail.com.

Zoran Sevarac

Jan 20, 2021, 7:49:57 PM1/20/21
to Jim Clarke, j...@tensorflow.org
Great, thanks. I'll let you know once it's done.

Zoran Sevarac

Jan 22, 2021, 11:07:45 AM1/22/21
to Jim Clarke, j...@tensorflow.org
I've created the pull request there are some things left open for discussion
Reply all
Reply to author
0 new messages