Stack Exchange
ZeroDivisionError : float division by zero(in CNN)
i want build a CNN model,and my code is :
model = Sequential([
    Embedding(len(dict) + 1,
             emb,
             weights=[embedding_matrix],
             input_length=maxlen,
             trainable=False),
    Conv1D(128,5,activation='relu'),
    MaxPooling1D(5),
    Conv1D(128,5,activation='relu'),
    MaxPooling1D(5),
    Conv1D(128,5,activation='relu'),
    MaxPooling1D(35),
    Flatten(),
    Dense(128,activation='relu'),
    Dense(2,activation='softmax'),
])

model.compile(loss='categorical_crossentropy',
              optimizer='rmsprop',
              metrics=['acc'])

print("model fitting - simplified convolutional neural network")
model.summary()
model.fit(x_train, y_train, validation_data=(x_val, y_val),
          nb_epoch=10, batch_size=128)

and  i get this error:
Traceback (most recent call last):
  File "/raid/daiy/PycharmProjects/SA/sa_cnn.py", line 122, in <module>
    Dense(1,activation='softmax'),
  File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 273, in __init__
    self.add(layer)
  File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 332, in add
    output_tensor = layer(self.outputs[0])
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 546, in __call__
    self.build(input_shapes[0])
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 798, in build
    constraint=self.W_constraint)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 418, in add_weight
    weight = initializer(shape, name=name)
  File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 65, in glorot_uniform
    s = np.sqrt(6. / (fan_in + fan_out))
ZeroDivisionError: float division by zero

i saw the issue on https://github.com/fchollet/keras/issues/2527.
i try Various forms of function API，but still get the error.Then i use another data,and no problem.but the difference between the two data is only the dimension.

What is a max_len value?

It's my set value:100
