TypeError: Expected int32, got None of type 'NoneType' instead
The error is raised by tf.zero() because the shape parameter should be a list of ints.
Indeed, as you build the computation graph, batch size is not (yet) know, unless you explicitly specify if.
Sometimes you need to specify shape information manually when working with Tensorflow Keras API.
One possible fix is to use tf.shape() function instead of shape attribute:
   b=tf.zeros(shape=[tf.shape(inputs)[0] ,self.num_capsule,1,self.input_num_capsule])

This line will run without error, but now the batch dimension of b is defined by a computation. It is dynamic and Keras doesn't know anymore, that it equals the batch size.
Maybe because of this softmax(b, axis=1) does not work anymore. Interestingly softmax() with the default axis setting works. So as a workaround we can juggle dimensions back and forth:
    c=tf.transpose(tf.nn.softmax(tf.transpose(b,perm=[0,2,3,1])),perm=[0,3,1,2])

To make the whole code work, you also need to specify shape information more precisely at the beginning of the code:
    reshape2=L.Reshape([6*6*128//8,8])(conv2)

Also you might notice, that all shape information is lost after the CapsuleLayer. You can check it with digitcaps.shape. But we can re-specify it:
    digitcaps = L.Reshape([3,16])(digitcaps)