Code Monkey home page Code Monkey logo

Comments (7)

Mingyu-academic avatar Mingyu-academic commented on July 19, 2024

ValueError Traceback (most recent call last)
in
5 vae = VAE(encoder, decoder)
6 vae.compile(optimizer=keras.optimizers.Adam())
----> 7 vae.fit(mnist_digits, epochs=30, batch_size=128)

/opt/conda/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
641 max_queue_size=max_queue_size,
642 workers=workers,
--> 643 use_multiprocessing=use_multiprocessing)
644
645 def evaluate(self,

/opt/conda/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs)
630 steps=steps_per_epoch,
631 validation_split=validation_split,
--> 632 shuffle=shuffle)
633
634 if validation_data:

/opt/conda/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, batch_size, check_steps, steps_name, steps, validation_split, shuffle, extract_tensors_from_dataset)
2388 target_tensors=target_tensors,
2389 run_eagerly=self.run_eagerly,
-> 2390 cloning=self._cloning)
2391
2392 # In graph mode, if we had just set inputs and targets as symbolic tensors

/opt/conda/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
456 self._self_setattr_tracking = False # pylint: disable=protected-access
457 try:
--> 458 result = method(self, *args, **kwargs)
459 finally:
460 self._self_setattr_tracking = previous_value # pylint: disable=protected-access

/opt/conda/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in compile(self, optimizer, loss, metrics, loss_weights, sample_weight_mode, weighted_metrics, target_tensors, distribute, **kwargs)
335
336 # Creates the model loss and weighted metrics sub-graphs.
--> 337 self._compile_weights_loss_and_weighted_metrics()
338
339 # Functions for train, test and predict will

/opt/conda/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
456 self._self_setattr_tracking = False # pylint: disable=protected-access
457 try:
--> 458 result = method(self, *args, **kwargs)
459 finally:
460 self._self_setattr_tracking = previous_value # pylint: disable=protected-access

/opt/conda/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in _compile_weights_loss_and_weighted_metrics(self, sample_weights)
1492 # loss_weight_2 * output_2_loss_fn(...) +
1493 # layer losses.
-> 1494 self.total_loss = self._prepare_total_loss(masks)
1495
1496 def _prepare_skip_target_masks(self):

/opt/conda/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in _prepare_total_loss(self, masks)
1593 if total_loss is None:
1594 if not self.losses:
-> 1595 raise ValueError('The model cannot be compiled '
1596 'because it has no loss to optimize.')
1597 else:

ValueError: The model cannot be compiled because it has no loss to optimize.

from keras-io.

angel-melchor avatar angel-melchor commented on July 19, 2024

I wasn't able to reproduce this issue while running tensorflow 2.2. What version are you using?

from keras-io.

sanka4rea avatar sanka4rea commented on July 19, 2024

I also met this issue with tensorflow 2.1, but fixed it by updating to 2.2

However, there is a warning:

WARNING:tensorflow:AutoGraph could not transform <bound method VAE.train_step of <main.VAE object at 0x7f8319e7da90>> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output.

from keras-io.

poedator avatar poedator commented on July 19, 2024

I encountered this issue using TF 2.1.0. Please update the example - some environments are still using TF 2.1.0 and older versions. For instance see conda's offering TD 2.1.0 for Windows here:

from keras-io.

sachinprasadhs avatar sachinprasadhs commented on July 19, 2024

Hi,

Please upgrade to the latest Keras/ Tensorflow version

You can use Keras using Tensorflow import as below.

import tensorflow as tf
input_layer = tf.keras.Input(shape=[100])

Let us know if you still face any error in latest version. Thanks!

from keras-io.

github-actions avatar github-actions commented on July 19, 2024

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

from keras-io.

github-actions avatar github-actions commented on July 19, 2024

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

from keras-io.

Related Issues (20)

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.