CNTK v2 library: Fixed a couple of tutorials that were using numpy imnterop to properly specify the dynamic axes of inputs; earlier the models were specifying inputs to have both sequence and dynamic axes though the fed numpy array data did not account for the sequence axis causing the batch dimension to be wrongly interpreted as the sequence dimension. This was working earlier due to a bug in interpreting numpy data which always interpreted the leading axis to be the bacth axis regardless of the actual dynamic axis the input has; fixing that bug exposed the issue with these notebooks
This commit is contained in:
Родитель
9d4a2f679a
Коммит
ef3aa02038
|
@ -590,8 +590,9 @@
|
|||
"num_output_classes = 2 #Remember we need to have 2 since we are trying to classify if the market goes up or down 1 hot encoded\n",
|
||||
"num_hidden_layers = 2\n",
|
||||
"hidden_layers_dim = 2 + num_days_back\n",
|
||||
"input = Input(input_dim)\n",
|
||||
"label = Input(num_output_classes)\n",
|
||||
"input_dynamic_axes = [C.Axis.default_batch_axis()]\n",
|
||||
"input = Input(input_dim, dynamic_axes=input_dynamic_axes)\n",
|
||||
"label = Input(num_output_classes, dynamic_axes=input_dynamic_axes)\n",
|
||||
"\n",
|
||||
"def create_model(input, num_output_classes):\n",
|
||||
" h = input\n",
|
||||
|
|
|
@ -388,8 +388,9 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"def build_graph(noise_shape, image_shape):\n",
|
||||
" Z = Input(noise_shape)\n",
|
||||
" X_real = Input(image_shape)\n",
|
||||
" input_dynamic_axes = [C.Axis.default_batch_axis()]\n",
|
||||
" Z = Input(noise_shape, dynamic_axes=input_dynamic_axes)\n",
|
||||
" X_real = Input(image_shape, dynamic_axes=input_dynamic_axes)\n",
|
||||
" X_real_scaled = 2*(X_real / 255.0) - 1.0\n",
|
||||
"\n",
|
||||
" # Create the model function for the generator and discriminator models\n",
|
||||
|
|
|
@ -448,9 +448,9 @@ class Function(cntk_py.Function):
|
|||
costly conversion but returns a somewhat opaque object.
|
||||
|
||||
Returns:
|
||||
list: list containing the gradients in the same order as
|
||||
the variables in ``wrt``. Each element has the same shape as
|
||||
``wrt`` including dynamic axes (such as the minibatch axis).
|
||||
dict or NumPy Array: Dict with keys of ``wrt`` variables and gradient values of
|
||||
``wrt`` variables. A single NumPy array if there is only one gradient value.
|
||||
Each element has the same shape as ``wrt`` including dynamic axes (such as the batch axis).
|
||||
'''
|
||||
|
||||
if len(self.outputs) != 1 :
|
||||
|
@ -462,7 +462,7 @@ class Function(cntk_py.Function):
|
|||
unique_wrt = set(wrt)
|
||||
output = [self.output]
|
||||
|
||||
# Since we do not return the computed results and use hem only to determine the shape
|
||||
# Since we do not return the computed results and use them only to determine the shape
|
||||
# of the root gradients, we run the forward pass with as_numpy=False regardless of the
|
||||
# actual as_numpy setting passed to this function
|
||||
state, results = self.forward(at, output, set(output), device, as_numpy=False)
|
||||
|
|
Загрузка…
Ссылка в новой задаче