• 1400/01/25

Sequential کتابخانه keras :

سلام استاد روز بخیر

وقتی میخوام کتابخانه keras رو import کنم انجام میشه و مشکلی نداره ولی وقتی میخوام از keras.models, Sequential رو import کنم ارور میده که چنین چیزی تو این کتابخانه وجود نداره. همین اتفاق برا Dense هم میفته.

بعد برام جالبه که چرا پنجره intellisence میتونه Sequential رو حدس بزنه

 

  • 1400/01/26
  • ساعت 07:05

سلام

این باگ مربوط به pycharm هست و در لینک زیر در مورد رفع این مشکل میتونید مطالعه کنید.

https://stackoverflow.com/questions/23248017/cannot-find-reference-xxx-in-init-py-python-pycharm

همچنین میتونید از یک IDE دیگه مثل ژوپیتر استفاده کنید.


  • 1400/01/26
  • ساعت 21:11

استاد اون مشکل حل شد ولی الان ی مشکل دیگ دارم

میگه: ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow ولی من ورژن tensorflow رو که چک کردم 2.4.4 بود

 

بعد ی مشکل دیگ از jupyter هم دارم وقتی کدزیر رو وارد میکنم

Model=Sequential()

 

ارور زیر میاد

---------------------------------------------------------------------------
InternalError                             Traceback (most recent call last)
<ipython-input-7-9bb8e4584392> in <module>
----> 1 Model=Sequential()
      2 Model.add(Dense(12, input_dim=8, activision='relu'))
      3 Model.add(Dense(8, activision='relu'))
      4 Model.add(Dense(1, input_dim=8, activision='sigmoid'))

F:\Anaconda3\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs)
    515     self._self_setattr_tracking = False  # pylint: disable=protected-access
    516     try:
--> 517       result = method(self, *args, **kwargs)
    518     finally:
    519       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

F:\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\sequential.py in __init__(self, layers, name)
    115     """
    116     # Skip the init in FunctionalModel since model doesn't have input/output yet
--> 117     super(functional.Functional, self).__init__(  # pylint: disable=bad-super-call
    118         name=name, autocast=False)
    119     base_layer.keras_api_gauge.get_cell('Sequential').set(True)

F:\Anaconda3\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs)
    515     self._self_setattr_tracking = False  # pylint: disable=protected-access
    516     try:
--> 517       result = method(self, *args, **kwargs)
    518     finally:
    519       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

F:\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in __init__(self, *args, **kwargs)
    291     self._steps_per_execution = None
    292 
--> 293     self._init_batch_counters()
    294     self._base_model_initialized = True
    295 

F:\Anaconda3\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs)
    515     self._self_setattr_tracking = False  # pylint: disable=protected-access
    516     try:
--> 517       result = method(self, *args, **kwargs)
    518     finally:
    519       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

F:\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in _init_batch_counters(self)
    299     # `evaluate`, and `predict`.
    300     agg = variables.VariableAggregationV2.ONLY_FIRST_REPLICA
--> 301     self._train_counter = variables.Variable(0, dtype='int64', aggregation=agg)
    302     self._test_counter = variables.Variable(0, dtype='int64', aggregation=agg)
    303     self._predict_counter = variables.Variable(

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py in __call__(cls, *args, **kwargs)
    260       return cls._variable_v1_call(*args, **kwargs)
    261     elif cls is Variable:
--> 262       return cls._variable_v2_call(*args, **kwargs)
    263     else:
    264       return super(VariableMetaclass, cls).__call__(*args, **kwargs)

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py in _variable_v2_call(cls, initial_value, trainable, validate_shape, caching_device, name, variable_def, dtype, import_scope, constraint, synchronization, aggregation, shape)
    242     if aggregation is None:
    243       aggregation = VariableAggregation.NONE
--> 244     return previous_getter(
    245         initial_value=initial_value,
    246         trainable=trainable,

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py in <lambda>(**kws)
    235                         shape=None):
    236     """Call on Variable class. Useful to force the signature."""
--> 237     previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
    238     for _, getter in ops.get_default_graph()._variable_creator_stack:  # pylint: disable=protected-access
    239       previous_getter = _make_getter(getter, previous_getter)

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py in default_variable_creator_v2(next_creator, **kwargs)
   2652   shape = kwargs.get("shape", None)
   2653 
-> 2654   return resource_variable_ops.ResourceVariable(
   2655       initial_value=initial_value,
   2656       trainable=trainable,

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\variables.py in __call__(cls, *args, **kwargs)
    262       return cls._variable_v2_call(*args, **kwargs)
    263     else:
--> 264       return super(VariableMetaclass, cls).__call__(*args, **kwargs)
    265 
    266 

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py in __init__(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, variable_def, import_scope, constraint, distribute_strategy, synchronization, aggregation, shape)
   1572       self._init_from_proto(variable_def, import_scope=import_scope)
   1573     else:
-> 1574       self._init_from_args(
   1575           initial_value=initial_value,
   1576           trainable=trainable,

F:\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py in _init_from_args(self, initial_value, trainable, collections, caching_device, name, dtype, constraint, synchronization, aggregation, distribute_strategy, shape)
   1715               self._update_uid = initial_value.checkpoint_position.restore_uid
   1716               initial_value = initial_value.wrapped_value
-> 1717             initial_value = ops.convert_to_tensor(initial_value,
   1718                                                   name="initial_value",
   1719                                                   dtype=dtype)

F:\Anaconda3\lib\site-packages\tensorflow\python\profiler\trace.py in wrapped(*args, **kwargs)
    161         with Trace(trace_name, **trace_kwargs):
    162           return func(*args, **kwargs)
--> 163       return func(*args, **kwargs)
    164 
    165     return wrapped

F:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types)
   1538 
   1539     if ret is None:
-> 1540       ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
   1541 
   1542     if ret is NotImplemented:

F:\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_conversion_registry.py in _default_conversion_function(***failed resolving arguments***)
     50 def _default_conversion_function(value, dtype, name, as_ref):
     51   del as_ref  # Unused.
---> 52   return constant_op.constant(value, dtype, name=name)
     53 
     54 

F:\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in constant(value, dtype, shape, name)
    262     ValueError: if called on a symbolic tensor.
    263   """
--> 264   return _constant_impl(value, dtype, shape, name, verify_shape=False,
    265                         allow_broadcast=True)
    266 

F:\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
    274       with trace.Trace("tf.constant"):
    275         return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
--> 276     return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
    277 
    278   g = ops.get_default_graph()

F:\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
    299 def _constant_eager_impl(ctx, value, dtype, shape, verify_shape):
    300   """Implementation of eager constant."""
--> 301   t = convert_to_eager_tensor(value, ctx, dtype)
    302   if shape is None:
    303     return t

F:\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
     95     except AttributeError:
     96       dtype = dtypes.as_dtype(dtype).as_datatype_enum
---> 97   ctx.ensure_initialized()
     98   return ops.EagerTensor(value, ctx.device_name, dtype)
     99 

F:\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py in ensure_initialized(self)
    509       opts = pywrap_tfe.TFE_NewContextOptions()
    510       try:
--> 511         config_str = self.config.SerializeToString()
    512         pywrap_tfe.TFE_ContextOptionsSetConfig(opts, config_str)
    513         if self._device_policy is not None:

F:\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py in config(self)
    928     """Return the ConfigProto with all runtime deltas applied."""
    929     # Ensure physical devices have been discovered and config has been imported
--> 930     self._initialize_physical_devices()
    931 
    932     config = config_pb2.ConfigProto()

F:\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py in _initialize_physical_devices(self)
   1251         return
   1252 
-> 1253       devs = pywrap_tfe.TF_ListPhysicalDevices()
   1254       self._physical_devices = [
   1255           PhysicalDevice(name=d.decode(),

InternalError: failed to get compute capability major for device: UNKNOWN ERROR (1); 0

logo-samandehi logo-anjoman-senfi