def model_inputs(real_dim, z_dim):
# inputs_real = tf.placeholder(tf.float32, (None, *real_dim), name='input_real')
inputs_real = tf.placeholder(tf.float32, (None, 32,32,3), name='input_real')
inputs_z = tf.placeholder(tf.float32, (None, z_dim), name='input_z')
return inputs_real, inputs_z
备注:real_dim =(32,32,3)
为什么别人的代码可以使用*real_dim,我的环境下确不行?
我预计最新的Python环境下,可以成功运行;
while current_index + batch_size <= self.shape[0]:
data_batch = get_batch(
self.data_files[current_index:current_index + batch_size],
# *self.shape[1:3],
self.image_mode,
*self.shape[1:3])
SyntaxError: only named arguments may follow *expression
30 down vote accepted
As Raymond Hettinger's answer points out, this may change has changed in Python 3 and here is a related proposal, which has been accepted. Especially related to the current question, here's one of the possible changes to that proposal that was discussed:
Only allow a starred expression as the last item in the exprlist. This would simplify the unpacking code a bit and allow for the starred expression to be assigned an iterator. This behavior was rejected because it would be too surprising.