visually explication of dense layer of keras?
You can find more details about the arguments of Dense Layer in Keras Sequential model here. 

Example

# as first layer in a sequential model:
model = Sequential()
model.add(Dense(32, input_shape=(16,)))
# now the model will take as input arrays of shape (*, 16)
# and output arrays of shape (*, 32)

# after the first layer, you don't need to specify
# the size of the input anymore:
model.add(Dense(32))


So basically 512 represents dimensionality of the output space of your model.