ProgLearn icon indicating copy to clipboard operation
ProgLearn copied to clipboard

Scene Segmentation with SynF

Open amyvanee opened this issue 3 years ago • 20 comments

#39 My issue is about adjusting Proglearn so we can do scene segmentation after flattening the images.

Reproducing code example:

def load_images(flatten_imgs):
    if flatten_imgs:
        X = np.array([cv2.imread(imgpath).flatten() for imgpath in imgpaths])
        Y = np.array([cv2.imread(lblpath).flatten() for lblpath in lblpaths])
    else:
        X = np.array([cv2.imread(imgpath) for imgpath in imgpaths])
        Y = np.array([cv2.imread(lblpath) for lblpath in lblpaths])
    return X,Y

flatten_imgs = True
X, Y = load_images(flatten_imgs)

from random_class_functions import Odif_experiment

slot_num = int(5000 / num_points_per_task)
slot_fold = range(slot_num)
shift_fold = range(1, shift_num + 1, 1)

# run the Odif model
n_trees = [tree_num]
iterable = product(n_trees, shift_fold, slot_fold)
df_results = Parallel(n_jobs=-1, verbose=0)(
    delayed(Odif_experiment)(
        X, Y, ntree, shift, slot, num_points_per_task, acorn=12345
    )
    for ntree, shift, slot in iterable
)

Error message

AttributeError                            Traceback (most recent call last)
<ipython-input-8-097c14639e16> in <module>
     10 n_trees = [tree_num]
     11 iterable = product(n_trees, shift_fold, slot_fold)
---> 12 df_results = Parallel(n_jobs=-1, verbose=0)(
     13     delayed(Odif_experiment)(
     14         X, Y, ntree, shift, slot, num_points_per_task, acorn=12345

~\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\parallel.py in __call__(self, iterable)
   1052 
   1053             with self._backend.retrieval_context():
-> 1054                 self.retrieve()
   1055             # Make sure that we get a last message telling us we are done
   1056             elapsed_time = time.time() - self._start_time

~\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\parallel.py in retrieve(self)
    931             try:
    932                 if getattr(self._backend, 'supports_timeout', False):
--> 933                     self._output.extend(job.get(timeout=self.timeout))
    934                 else:
    935                     self._output.extend(job.get())

~\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\_parallel_backends.py in wrap_future_result(future, timeout)
    540         AsyncResults.get from multiprocessing."""
    541         try:
--> 542             return future.result(timeout=timeout)
    543         except CfTimeoutError as e:
    544             raise TimeoutError from e

~\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py in result(self, timeout)
    443                     raise CancelledError()
    444                 elif self._state == FINISHED:
--> 445                     return self.__get_result()
    446                 else:
    447                     raise TimeoutError()

~\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py in __get_result(self)
    388         if self._exception:
    389             try:
--> 390                 raise self._exception
    391             finally:
    392                 # Break a reference cycle with the exception in self._exception

AttributeError: 'bool' object has no attribute 'any'

Version information

  • OS: [e.g. macOS] Windows
  • Python Version [e.g. 3.7.3]: Python 3.7.3
  • Package Version [e.g. 0.0.1]: Proglearn 0.0.5

amyvanee avatar Nov 04 '21 17:11 amyvanee

@amyvanee did you try fitting proglearn for one task only? I would not try it with other people's code. Please try to train it on only one task using add_task first. Let's not use parallel for now.

jdey4 avatar Nov 04 '21 20:11 jdey4

@amyvanee Which version of proglearn are you using?

PSSF23 avatar Nov 04 '21 20:11 PSSF23

@PSSF23 Sorry about that, I am using Proglearn 0.0.5

amyvanee avatar Nov 06 '21 13:11 amyvanee

@jdey4 I tried going to the basics more and initializing a LifelongClassification Forest, but I got an error.

%  Declare the progressive learner model (L2F)
learner = LifelongClassificationForest()

% add the task
learner.add_task(
                flat_x,
                flat_y,
                task_id=0
                )

And the output,

TypeError                                 Traceback (most recent call last)
TypeError: only size-1 arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
<ipython-input-18-74e8ef13550e> in <module>
      3 
      4 # add the task
----> 5 learner.add_task(
      6                 flat_x,
      7                 flat_y,

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\forest.py in add_task(self, X, y, task_id, n_estimators, tree_construction_proportion, kappa, max_depth)
    122             max_depth = self.default_max_depth
    123 
--> 124         X, y = check_X_y(X, y)
    125         return self.pl_.add_task(
    126             X,

~\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, estimator)
    954         raise ValueError("y cannot be None")
    955 
--> 956     X = check_array(
    957         X,
    958         accept_sparse=accept_sparse,

~\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
    736                     array = array.astype(dtype, casting="unsafe", copy=False)
    737                 else:
--> 738                     array = np.asarray(array, order=order, dtype=dtype)
    739             except ComplexWarning as complex_warning:
    740                 raise ValueError(

~\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\core\_asarray.py in asarray(a, dtype, order)
     81 
     82     """
---> 83     return array(a, dtype, copy=False, order=order)
     84 
     85 

ValueError: setting an array element with a sequence.

I double checked, and below are shapes,

  • flat_x.shape = (64,)
  • flat_y.shape = (64,)
  • flat_x[0].shape = (10890000,)
  • flat_y[0].shape = (9000000,)
  • data_x[0].shape = (2200, 1650, 3)
  • data_y[0].shape = (2000, 1500, 3)

If I try putting in any of the other data, I get an error that the input should be 2D.

Also, it is weird that the shape of data_y[0] is not the same as for data_x[0]?

Thank you for your help!

amyvanee avatar Nov 06 '21 14:11 amyvanee

@amyvanee always use the latest version, which is 0.0.6 now. And what are data_x & flat_x & ... ? We have no idea what they are, but the y seems too large. What are the labels of these images?

PSSF23 avatar Nov 06 '21 15:11 PSSF23

@PSSF23

  • Thank you! I tried updating to Proglearn 0.0.6, using pip install proglearn --upgrade but I got an error. error: Could not find module 'hdf5.dll' (or one of its dependencies). Try using the full path with constructor syntax. Loading library to get version: hdf5.dll

  • The images are from the ADE20K consistency set

  • There are 64 images, each 2D with RGB so the image arrays are 3D. X is the original image, and Y is the image where each pixel is annotated by the object it is. (I am not sure why, but the array dimensions do not match up between X and Y)

  • data_x and data_y are the original images and the annotated image. flat_x and flat_y are the flattened version of these images, since we thought flattening them to be 1D would help with insertion into proglearn.

Thank you for your help!

amyvanee avatar Nov 07 '21 14:11 amyvanee

  • The error is unrelated to proglearn. I have never seen it before.
  • Your fitting process doesn't make sense. Based on your descriptions, each y image is different so there's no valid classification.

PSSF23 avatar Nov 07 '21 14:11 PSSF23

BTW are you working on #39 ? Why didn't you comment on it?

PSSF23 avatar Nov 07 '21 14:11 PSSF23

@PSSF23

  • Thank you, I will try seeing if I can fix it another way!
  • Yes that was my concern since I know proglearn takes in the true labels as one label per image (so a 2D image where the output is, for example, "dog") -- would I need to make modifications to the proglearn code to do this? I know scikit actually has this feature with random forests, and it seems to work. I still need to quantify how accurate it is.
  • Yes, I am working on issue #39! Sorry I should have commented there.

amyvanee avatar Nov 07 '21 14:11 amyvanee

@amyvanee No problem. As the example in your link, sklearn RF must rely on skimage to process the images. You can definitely follow it and try it on proglearn. Odif (LifelongClassificationForest) would replace the RandomForestClassifier in that example.

Comment on #39 so it could be assigned to you. Are there other students sharing the issue?

PSSF23 avatar Nov 07 '21 14:11 PSSF23

@PSSF23 Thank you, I will try that! Yes, I am working with Narayani Wagle (@nhwagle) and Kevin Rao (@KhelmholtzR) We made a separate GitHub repo with some of our progress

amyvanee avatar Nov 07 '21 19:11 amyvanee

@amyvanee @nhwagle @KhelmholtzR you should all comment on #39 and create your independent sub-issue here. So we can keep track of what you are working on.

PSSF23 avatar Nov 07 '21 19:11 PSSF23

@PSSF23 Thank you for your help!

I tried using LifelongClassificationForest, but when I tried importing it, I got the following error. Have you seen this before?

---------------------------------------------------------------------------
AlreadyExistsError                        Traceback (most recent call last)
<ipython-input-13-38d6cdc00b7f> in <module>
----> 1 from proglearn.forest import LifelongClassificationForest
      2 
      3 flatten_imgs = False
      4 data_x, data_y = load_images(flatten_imgs)
      5 

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_backward_compatible(spec)

<frozen zipimport> in load_module(self, fullname)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\__init__.py in <module>
----> 1 from .forest import *
      2 from .network import *
      3 
      4 __version__ = "0.0.5"
      5 __all__ = [

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_backward_compatible(spec)

<frozen zipimport> in load_module(self, fullname)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\forest.py in <module>
      4 """
      5 from .progressive_learner import ClassificationProgressiveLearner
----> 6 from .transformers import TreeClassificationTransformer
      7 from .voters import TreeClassificationVoter
      8 from .deciders import SimpleArgmaxAverage

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_backward_compatible(spec)

<frozen zipimport> in load_module(self, fullname)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\transformers.py in <module>
     11 
     12 
---> 13 class NeuralClassificationTransformer(BaseTransformer):
     14     """
     15     A class used to transform data from a category to a specialized representation.

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\transformers.py in NeuralClassificationTransformer()
     60         fit_kwargs={
     61             "epochs": 100,
---> 62             "callbacks": [keras.callbacks.EarlyStopping(patience=5, monitor="val_acc")],
     63             "verbose": False,
     64             "validation_split": 0.33,

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\util\lazy_loader.py in __getattr__(self, item)
     60 
     61   def __getattr__(self, item):
---> 62     module = self._load()
     63     return getattr(module, item)
     64 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\util\lazy_loader.py in _load(self)
     43     """Load the module and insert it into the parent's globals."""
     44     # Import the target module and insert it into the parent's namespace
---> 45     module = importlib.import_module(self.__name__)
     46     self._parent_module_globals[self._local_name] = module
     47 

~\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\__init__.py in <module>
     23 
     24 # See b/110718070#comment18 for more details about this import.
---> 25 from keras import models
     26 
     27 from keras.engine.input_layer import Input

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\models.py in <module>
     18 import tensorflow.compat.v2 as tf
     19 from keras import backend
---> 20 from keras import metrics as metrics_module
     21 from keras import optimizer_v1
     22 from keras.engine import functional

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\metrics.py in <module>
     24 
     25 import numpy as np
---> 26 from keras import activations
     27 from keras import backend
     28 from keras.engine import base_layer

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\activations.py in <module>
     18 
     19 from keras import backend
---> 20 from keras.layers import advanced_activations
     21 from keras.utils.generic_utils import deserialize_keras_object
     22 from keras.utils.generic_utils import serialize_keras_object

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\layers\__init__.py in <module>
     21 
     22 # Generic layers.
---> 23 from keras.engine.input_layer import Input
     24 from keras.engine.input_layer import InputLayer
     25 from keras.engine.input_spec import InputSpec

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\input_layer.py in <module>
     19 from keras import backend
     20 from keras.distribute import distributed_training_utils
---> 21 from keras.engine import base_layer
     22 from keras.engine import keras_tensor
     23 from keras.engine import node as node_module

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\base_layer.py in <module>
     41 from keras.engine import node as node_module
     42 from keras.mixed_precision import autocast_variable
---> 43 from keras.mixed_precision import loss_scale_optimizer
     44 from keras.mixed_precision import policy
     45 from keras.saving.saved_model import layer_serialization

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\mixed_precision\loss_scale_optimizer.py in <module>
     16 
     17 from keras import backend
---> 18 from keras import optimizers
     19 from keras.mixed_precision import loss_scale as keras_loss_scale_module
     20 from keras.optimizer_v2 import optimizer_v2

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\optimizers.py in <module>
     24 from keras.optimizer_v1 import Optimizer
     25 from keras.optimizer_v1 import TFOptimizer
---> 26 from keras.optimizer_v2 import adadelta as adadelta_v2
     27 from keras.optimizer_v2 import adagrad as adagrad_v2
     28 from keras.optimizer_v2 import adam as adam_v2

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\optimizer_v2\adadelta.py in <module>
     20 import numpy as np
     21 from keras import backend_config
---> 22 from keras.optimizer_v2 import optimizer_v2
     23 from tensorflow.python.util.tf_export import keras_export
     24 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\optimizer_v2\optimizer_v2.py in <module>
     34 
     35 
---> 36 keras_optimizers_gauge = tf.__internal__.monitoring.BoolGauge(
     37     "/tensorflow/api/keras/optimizers", "keras optimizer usage", "method")
     38 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\eager\monitoring.py in __init__(self, name, description, *labels)
    358       *labels: The label list of the new metric.
    359     """
--> 360     super(BoolGauge, self).__init__('BoolGauge', _bool_gauge_methods,
    361                                     len(labels), name, description, *labels)
    362 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\eager\monitoring.py in __init__(self, metric_name, metric_methods, label_length, *args)
    133           self._metric_name, len(self._metric_methods)))
    134 
--> 135     self._metric = self._metric_methods[self._label_length].create(*args)
    136 
    137   def __del__(self):

AlreadyExistsError: Another metric with the same name already exists.

amyvanee avatar Nov 07 '21 19:11 amyvanee

  • First, code block uses ```
  • Second, you are still using 0.0.5

PSSF23 avatar Nov 07 '21 19:11 PSSF23

@PSSF23 Thank you for the fix! Yeah unfortunately I am still having trouble upgrading to 0.0.5, I will focus on that then before trying out Odif. Thank you!

amyvanee avatar Nov 07 '21 20:11 amyvanee

Cool. Having up-to-date software is always the minimum necessity for development. Some of your problems might already be solved by 0.0.6.

PSSF23 avatar Nov 07 '21 20:11 PSSF23

@PSSF23 I was able to update to Proglearn 0.0.6! However, I still get the same error?

Here is my code,

from proglearn.forest import LifelongClassificationForest

img = image_grey
training_labels = label_grey

sigma_min = 1
sigma_max = 16
features_func = partial(feature.multiscale_basic_features,
                        intensity=True, edges=False, texture=True,
                        sigma_min=sigma_min, sigma_max=sigma_max,
                        multichannel=True)
features = features_func(img)
clf = LifelongClassificationForest(n_estimators=50, n_jobs=-1,
                             max_depth=10, max_samples=0.05)
clf = future.fit_segmenter(training_labels, features, clf)
result = future.predict_segmenter(features, clf)

fig, ax = plt.subplots(1, 2, sharex=True, sharey=True, figsize=(9, 4))
ax[0].imshow(segmentation.mark_boundaries(img, result, mode='thick'))
ax[0].contour(training_labels)
ax[0].set_title('Image, mask and segmentation boundaries')
ax[1].imshow(result)
ax[1].set_title('Segmentation')
fig.tight_layout()

Here is the error

---------------------------------------------------------------------------
AlreadyExistsError                        Traceback (most recent call last)
<ipython-input-15-3acbe7b9e2c4> in <module>
----> 1 from proglearn.forest import LifelongClassificationForest
      2 
      3 img = image_grey
      4 training_labels = label_grey
      5 

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_backward_compatible(spec)

<frozen zipimport> in load_module(self, fullname)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\__init__.py in <module>
----> 1 from .forest import *
      2 from .network import *
      3 
      4 __version__ = "0.0.5"
      5 __all__ = [

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_backward_compatible(spec)

<frozen zipimport> in load_module(self, fullname)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\forest.py in <module>
      4 """
      5 from .progressive_learner import ClassificationProgressiveLearner
----> 6 from .transformers import TreeClassificationTransformer
      7 from .voters import TreeClassificationVoter
      8 from .deciders import SimpleArgmaxAverage

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_backward_compatible(spec)

<frozen zipimport> in load_module(self, fullname)

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\transformers.py in <module>
     11 
     12 
---> 13 class NeuralClassificationTransformer(BaseTransformer):
     14     """
     15     A class used to transform data from a category to a specialized representation.

~\AppData\Local\Programs\Python\Python39\lib\site-packages\proglearn-0.0.5-py3.9.egg\proglearn\transformers.py in NeuralClassificationTransformer()
     60         fit_kwargs={
     61             "epochs": 100,
---> 62             "callbacks": [keras.callbacks.EarlyStopping(patience=5, monitor="val_acc")],
     63             "verbose": False,
     64             "validation_split": 0.33,

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\util\lazy_loader.py in __getattr__(self, item)
     60 
     61   def __getattr__(self, item):
---> 62     module = self._load()
     63     return getattr(module, item)
     64 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\util\lazy_loader.py in _load(self)
     43     """Load the module and insert it into the parent's globals."""
     44     # Import the target module and insert it into the parent's namespace
---> 45     module = importlib.import_module(self.__name__)
     46     self._parent_module_globals[self._local_name] = module
     47 

~\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\__init__.py in <module>
     23 
     24 # See b/110718070#comment18 for more details about this import.
---> 25 from keras import models
     26 
     27 from keras.engine.input_layer import Input

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\models.py in <module>
     18 import tensorflow.compat.v2 as tf
     19 from keras import backend
---> 20 from keras import metrics as metrics_module
     21 from keras import optimizer_v1
     22 from keras.engine import functional

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\metrics.py in <module>
     24 
     25 import numpy as np
---> 26 from keras import activations
     27 from keras import backend
     28 from keras.engine import base_layer

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\activations.py in <module>
     18 
     19 from keras import backend
---> 20 from keras.layers import advanced_activations
     21 from keras.utils.generic_utils import deserialize_keras_object
     22 from keras.utils.generic_utils import serialize_keras_object

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\layers\__init__.py in <module>
     21 
     22 # Generic layers.
---> 23 from keras.engine.input_layer import Input
     24 from keras.engine.input_layer import InputLayer
     25 from keras.engine.input_spec import InputSpec

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\input_layer.py in <module>
     19 from keras import backend
     20 from keras.distribute import distributed_training_utils
---> 21 from keras.engine import base_layer
     22 from keras.engine import keras_tensor
     23 from keras.engine import node as node_module

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\base_layer.py in <module>
     41 from keras.engine import node as node_module
     42 from keras.mixed_precision import autocast_variable
---> 43 from keras.mixed_precision import loss_scale_optimizer
     44 from keras.mixed_precision import policy
     45 from keras.saving.saved_model import layer_serialization

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\mixed_precision\loss_scale_optimizer.py in <module>
     16 
     17 from keras import backend
---> 18 from keras import optimizers
     19 from keras.mixed_precision import loss_scale as keras_loss_scale_module
     20 from keras.optimizer_v2 import optimizer_v2

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\optimizers.py in <module>
     24 from keras.optimizer_v1 import Optimizer
     25 from keras.optimizer_v1 import TFOptimizer
---> 26 from keras.optimizer_v2 import adadelta as adadelta_v2
     27 from keras.optimizer_v2 import adagrad as adagrad_v2
     28 from keras.optimizer_v2 import adam as adam_v2

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\optimizer_v2\adadelta.py in <module>
     20 import numpy as np
     21 from keras import backend_config
---> 22 from keras.optimizer_v2 import optimizer_v2
     23 from tensorflow.python.util.tf_export import keras_export
     24 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\optimizer_v2\optimizer_v2.py in <module>
     34 
     35 
---> 36 keras_optimizers_gauge = tf.__internal__.monitoring.BoolGauge(
     37     "/tensorflow/api/keras/optimizers", "keras optimizer usage", "method")
     38 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\eager\monitoring.py in __init__(self, name, description, *labels)
    358       *labels: The label list of the new metric.
    359     """
--> 360     super(BoolGauge, self).__init__('BoolGauge', _bool_gauge_methods,
    361                                     len(labels), name, description, *labels)
    362 

~\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\eager\monitoring.py in __init__(self, metric_name, metric_methods, label_length, *args)
    133           self._metric_name, len(self._metric_methods)))
    134 
--> 135     self._metric = self._metric_methods[self._label_length].create(*args)
    136 
    137   def __del__(self):

AlreadyExistsError: Another metric with the same name already exists.

amyvanee avatar Nov 09 '21 20:11 amyvanee

@amyvanee ~~you should use from proglearn import LifelongClassificationForest. We currently have no submodules for the package.~~ The original command is fine.

PSSF23 avatar Nov 09 '21 20:11 PSSF23

@PSSF23 Thank you! I still do seem to be getting the same error though that it already exists? I am not sure why it thinks it already exists?

amyvanee avatar Nov 10 '21 03:11 amyvanee

@amyvanee I just realized you were still on 0.0.5 version (see error messages). You need to clean up and reboot everything to make sure you have the right version.

The command I gave works correctly on my machine.

PSSF23 avatar Nov 10 '21 03:11 PSSF23