Code Monkey home page Code Monkey logo

tensorflow_2.0_tutorial's People

Contributors

apm5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tensorflow_2.0_tutorial's Issues

should word_num be len(word_index)+1?

Hi:

Thank you for providing such a good material.

In this file simple_example.py
the parameter word_num is 10000, while i run this code in my computer, an exception is raised:
InvalidArgumentError: indices[26,0] = 12089 is not in [0, 10000).

I think word_num should be set to len(word_index)+1, so i changed and tested again, and it worked.

I wonder if the change is right? or is there something i forget?

Thank you.

TypeError: Value passed to parameter 'input' has DataType uint8 not in list of allowed values: float16, bfloat16, float32, float64, int32

When running the ResNet_CIFAR.py, it will raise an error, after first epoch training.

100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 390/390 [00:42<00:00,  9.27it/s]
ce_loss:1.753367, l2_loss:0.201427, accuracy:0.355829
  0%|                                                                                                                   | 0/50 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "tf2_train_cifar.py", line 190, in <module>
    test(model, test_images, test_labels)
  File "tf2_train_cifar.py", line 154, in test
    loss, prediction = test_step(model, x, y)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 568, in __call__
    result = self._call(*args, **kwds)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 615, in _call
    self._initialize(args, kwds, add_initializers_to=initializers)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 497, in _initialize
    *args, **kwds))
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/function.py", line 2389, in _get_concrete_function_internal_garbage_collected
    graph_function, _, _ = self._maybe_define_function(args, kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/function.py", line 2703, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/function.py", line 2593, in _create_graph_function
    capture_by_value=self._capture_by_value),
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/func_graph.py", line 978, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 439, in wrapped_fn
    return weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/func_graph.py", line 968, in wrapper
    raise e.ag_error_metadata.to_exception(e)
TypeError: in converted code:

    tf2_train_cifar.py:116 test_step  *
        prediction = model(x, training=False)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/base_layer.py:778 __call__
        outputs = call_fn(cast_inputs, *args, **kwargs)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/network.py:717 call
        convert_kwargs_to_constants=base_layer_utils.call_context().saving)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/network.py:891 _run_internal_graph
        output_tensors = layer(computed_tensors, **kwargs)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/base_layer.py:778 __call__
        outputs = call_fn(cast_inputs, *args, **kwargs)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/layers/convolutional.py:213 call
        outputs = self._convolution_op(inputs, self.kernel)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/nn_ops.py:1176 __call__
        return self.conv_op(inp, filter)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/nn_ops.py:662 __call__
        return self.call(inp, filter)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/nn_ops.py:252 __call__
        name=self.name)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/nn_ops.py:2052 conv2d
        name=name)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/gen_nn_ops.py:969 conv2d
        data_format=data_format, dilations=dilations, name=name)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/op_def_library.py:576 _apply_op_helper
        param_name=input_name)
    /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/op_def_library.py:61 _SatisfiesTypeConstraint
        ", ".join(dtypes.as_dtype(x).name for x in allowed_list)))

    TypeError: Value passed to parameter 'input' has DataType uint8 not in list of allowed values: float16, bfloat16, float32, float64, int32

Then I found that the error occurred in test function

x = images[i * test_batch_size: (i + 1) * test_batch_size, :, :, :]

Where after reading the images, unlike train function, after images_augment, the dtype will be tf.float32.
But for test function, it is still uint8 type.

The solution is to add a line:

x = tf.cast(x, tf.float32)

is_training in BatchNormalization

Hi,

I found the batch normalization in CNN/ResNet_CIFAR.py did not call the is_training to differentiate the training and test process. Is that correct? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.