Q:

Understanding the shape of tensorflow placeholders

I am reading this code and I would like to understand about its implementation.

One of the first things that I would like to know, is that what is the shape of some tensor objects (placeholders) such as x_init, xs, h_init, y_init, y_sample, etc. 
I wrote a line of code such as print(xs.shape) but it wont work.
How can I understand the shape of these parameters (tensors)? And can I write something like the following in NumPy?

The part of code that defines these tensors look like this:
x_init = tf.placeholder(tf.float32, shape=(args.init_batch_size,) + obs_shape)

xs = [tf.placeholder(tf.float32, shape=(args.batch_size, ) + obs_shape)
      for i in range(args.nr_gpu)]

# if the model is class-conditional we'll set up label placeholders +
# one-hot encodings 'h' to condition on if args.class_conditional:

num_labels = train_data.get_num_labels()
y_init = tf.placeholder(tf.int32, shape=(args.init_batch_size,))
h_init = tf.one_hot(y_init, num_labels)
y_sample = np.split(
    np.mod(np.arange(args.batch_size * args.nr_gpu), num_labels), args.nr_gpu)
h_sample = [tf.one_hot(tf.Variable(
    y_sample[i], trainable=False), num_labels) for i in range(args.nr_gpu)]

A:

The shape is assembled from different command line parameters:

obs_shape is the shape of the input images, e.g., (32, 32, 3)
args.init_batch_size and args.batch_size are the values from command line. It could be for example 30 and 40.

Then shape of x_init is the concatenation of init_batch_size and  obs_shape: (30, 32, 32, 3). Correspondingly, the shape of each item in xs is (40, 32, 32, 3).
You couldn't evaluate xs.shape, because xs is a list of placeholders. You can evaluate xs[0].shape instead.
y_sample and h_sample are the lists of tensors as well. The first one contains (batch_size, num_labels) tensors, the second one (num_labels, ).

