我知道在使用Rails时,有一个html表单的命名约定,允许输入值在表单提交时自动作为params发送给控制器。例如,当您向控制器提交ValueError Traceback (most recent call last)
/home/user/conv_filter_visualization.py in <module>()
97 # we run gradient ascent for 20 steps
/home/user/.local/lib/python3.4/site-packages/theano/compile/function_module.py in __call__(self, *args, **kwargs)
857 t0_fn = time.time()
858 try:
--> 859 outputs = self.fn()
860 except Exception:
861 if hasattr(self.fn, 'position_of_error'):
ValueError: CorrMM images and kernel must have the same stack size
Apply node that caused the error: CorrMM{valid, (1, 1)}(convolution2d_input_1, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 8
Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)]
Inputs shapes: [(1, 3, 300, 300), (16, 1, 20, 20)]
Inputs strides: [(1080000, 360000, 1200, 4), (1600, 1600, -80, -4)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Elemwise{add,no_inplace}(CorrMM{valid, (1, 1)}.0, Reshape{4}.0), Elemwise{Composite{(i0 * (Abs(i1) + i2 + i3))}}[(0, 1)](TensorConstant{(1, 1, 1, 1) of 0.5}, Elemwise{add,no_inplace}.0, CorrMM{valid, (1, 1)}.0, Reshape{4}.0)]]
Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "/home/user/.local/lib/python3.4/site-packages/keras/models.py", line 787, in from_config
model.add(layer)
File "/home/user/.local/lib/python3.4/site-packages/keras/models.py", line 114, in add
layer.create_input_layer(batch_input_shape, input_dtype)
File "/home/user/.local/lib/python3.4/site-packages/keras/engine/topology.py", line 341, in create_input_layer
self(x)
File "/home/user/.local/lib/python3.4/site-packages/keras/engine/topology.py", line 485, in __call__
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home/user/.local/lib/python3.4/site-packages/keras/engine/topology.py", line 543, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home/user/.local/lib/python3.4/site-packages/keras/engine/topology.py", line 148, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/home/user/.local/lib/python3.4/site-packages/keras/layers/convolutional.py", line 356, in call
filter_shape=self.W_shape)
File "/home/user/.local/lib/python3.4/site-packages/keras/backend/theano_backend.py", line 862, in conv2d
filter_shape=filter_shape)
时,您可以使用<input id="user_name" name="user[name]"/>
捕获该输入的值。
我也知道如果我提交一个选择标签,例如:
params[:user][:name]
我可以在控制器中使用<select name="user[car]">
<option value="1" selected>Volvo</option>
<option value="2">Saab</option>
<option value="3">Mercedes</option>
<option value="4">Audi</option>
</select>
捕获值1
。
但是如果我有相同的选择标签并且我想发送两者汽车的ID 和汽车的名称,我该怎么办?有没有办法在没有创建额外的文本字段的情况下接收选择标记的params[:user][:car]
事件上的汽车名称?