Lung-Diseases-Classifier icon indicating copy to clipboard operation
Lung-Diseases-Classifier copied to clipboard

OPTIMIZED CNN ERROR

Open Jk1091997 opened this issue 2 years ago • 0 comments

While implemening every code in optimized cnn sample dataset,im getting error. 1.PRETRAINED MODEL ONLY AND CNN MODEL Epoch 1/20

ValueError Traceback (most recent call last) in 37 steps_per_epoch=int(train_labels.shape[0] / batch_size), 38 validation_data=(valid_tensors, valid_labels), ---> 39 epochs=epochs, callbacks=[checkpointer, log, earlystop], verbose=1) 40 41 # Show total training time

~\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch) 1987 use_multiprocessing=use_multiprocessing, 1988 shuffle=shuffle, -> 1989 initial_epoch=initial_epoch) 1990 1991 @doc_controls.do_not_generate_docs

~\anaconda3\envs\hello-tf\lib\site-packages\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_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing) 1182 _r=1): 1183 callbacks.on_train_batch_begin(step) -> 1184 tmp_logs = self.train_function(iterator) 1185 if data_handler.should_sync: 1186 context.async_wait()

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\def_function.py in call(self, *args, **kwds) 883 884 with OptionalXlaContext(self._jit_compile): --> 885 result = self._call(*args, **kwds) 886 887 new_tracing_count = self.experimental_get_tracing_count()

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\def_function.py in _call(self, *args, **kwds) 922 # In this case we have not created variables on the first call. So we can 923 # run the first trace but we should fail if variables are created. --> 924 results = self._stateful_fn(*args, **kwds) 925 if self._created_variables and not ALLOW_DYNAMIC_VARIABLE_CREATION: 926 raise ValueError("Creating variables on a non-first call to a function"

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\function.py in call(self, *args, **kwargs) 3036 with self._lock: 3037 (graph_function, -> 3038 filtered_flat_args) = self._maybe_define_function(args, kwargs) 3039 return graph_function._call_flat( 3040 filtered_flat_args, captured_inputs=graph_function.captured_inputs) # pylint: disable=protected-access

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\function.py in _maybe_define_function(self, args, kwargs) 3458 call_context_key in self._function_cache.missed): 3459 return self._define_function_with_shape_relaxation( -> 3460 args, kwargs, flat_args, filtered_flat_args, cache_key_context) 3461 3462 self._function_cache.missed.add(call_context_key)

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\function.py in _define_function_with_shape_relaxation(self, args, kwargs, flat_args, filtered_flat_args, cache_key_context) 3380 3381 graph_function = self._create_graph_function( -> 3382 args, kwargs, override_flat_arg_shapes=relaxed_arg_shapes) 3383 self._function_cache.arg_relaxed[rank_only_cache_key] = graph_function 3384

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes) 3306 arg_names=arg_names, 3307 override_flat_arg_shapes=override_flat_arg_shapes, -> 3308 capture_by_value=self._capture_by_value), 3309 self._function_attributes, 3310 function_spec=self.function_spec,

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\framework\func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes, acd_record_initial_resource_uses) 1005 _, original_func = tf_decorator.unwrap(python_func) 1006 -> 1007 func_outputs = python_func(*func_args, **func_kwargs) 1008 1009 # invariant: func_outputs contains only Tensors, CompositeTensors,

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\def_function.py in wrapped_fn(*args, **kwds) 666 # the function a weak reference to itself to avoid a reference cycle. 667 with OptionalXlaContext(compile_with_xla): --> 668 out = weak_wrapped_fn().wrapped(*args, **kwds) 669 return out 670

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\framework\func_graph.py in wrapper(*args, **kwargs) 992 except Exception as e: # pylint:disable=broad-except 993 if hasattr(e, "ag_error_metadata"): --> 994 raise e.ag_error_metadata.to_exception(e) 995 else: 996 raise

ValueError: in user code:

C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\training.py:853 train_function  *
    return step_function(self, iterator)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\training.py:842 step_function  **
    outputs = model.distribute_strategy.run(run_step, args=(data,))
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:1286 run
    return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:2849 call_for_each_replica
    return self._call_for_each_replica(fn, args, kwargs)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:3632 _call_for_each_replica
    return fn(*args, **kwargs)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\training.py:835 run_step  **
    outputs = model.train_step(data)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\training.py:787 train_step
    y_pred = self(x, training=True)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\base_layer.py:1020 __call__
    input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
C:\Users\91984\anaconda3\envs\hello-tf\lib\site-packages\keras\engine\input_spec.py:202 assert_input_compatibility
    ' input tensors. Inputs received: ' + str(inputs))

ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=float32>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None) dtype=int32>]

2.Train with extra data and spacial transformer Epoch 1/20

TypeError Traceback (most recent call last) in 13 model.fit((train_tensors, train_data), train_labels, 14 validation_data=((valid_tensors, valid_data), valid_labels), ---> 15 epochs = epochs, batch_size = batch_size, callbacks = [checkpointer, log, earlystop],verbose=1) 16 # def train_generator(x, y, batch_size): 17 # train_datagen = ImageDataGenerator(

~\anaconda3\envs\hello-tf\lib\site-packages\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_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing) 1182 _r=1): 1183 callbacks.on_train_batch_begin(step) -> 1184 tmp_logs = self.train_function(iterator) 1185 if data_handler.should_sync: 1186 context.async_wait()

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\def_function.py in call(self, *args, **kwds) 883 884 with OptionalXlaContext(self._jit_compile): --> 885 result = self._call(*args, **kwds) 886 887 new_tracing_count = self.experimental_get_tracing_count()

~\anaconda3\envs\hello-tf\lib\site-packages\tensorflow\python\eager\def_function.py in _call(self, *args, **kwds) 915 # In this case we have created variables on the first call, so we run the 916 # defunned version which is guaranteed to never create variables. --> 917 return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable 918 elif self._stateful_fn is not None: 919 # Release the lock early so that multiple threads can perform the call

TypeError: 'NoneType' object is not callable

Jk1091997 avatar Jun 14 '22 07:06 Jk1091997