Replies: 2 comments
|
hello @teodoramohaiu-ops , Thank you for taking the time to open an issue. For better consistency across all models I am switching model.trainable_weights as a property that should be handled through model._trainable_weights. Here is how it looks like: class TaFengMNL(ChoiceModel):
"""Custom model for the TaFeng dataset."""
def __init__(self, **kwargs):
"""Instantiation of our custom model."""
# Standard inheritance stuff
super().__init__(**kwargs)
# Instantiation of base utilties weights
# We have 25 items in the dataset making 25 weights
self.base_utilities = tf.Variable(
tf.random_normal_initializer(0.0, 0.02, seed=42)(shape=(1, 25))
)
# Instantiation of price elasticities weights
# We have 3 age categories making 3 weights
self.price_elasticities = tf.Variable(
tf.random_normal_initializer(0.0, 0.02, seed=42)(shape=(1, 3))
)
# Don't forget to add the weights to be optimized in self.weights !
self._trainable_weights = [self.base_utilities, self.price_elasticities]
@property
def trainable_weights(self):
return self._trainable_weightsAnd the remaining code should be ok - only the "tolerance" argument that has become "lbfgs_tolerance". |
0 replies
|
For the environment you can use the requirements.txt file with Python 3.9-3.12. On my side, I am working most of the time with Python 3.11.4 and Tensorflow 2.13. Let me know if you need further information ! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi!
First of all, congratulations for this complex package!
We're currently working on an assortment optimization project using Big Data and we've decided to use it as it exactly meets our goals.
I was trying to run your notebook from auxiliary_tools/assortment_example.ipynb, but I encounter the following error:
AttributeError Traceback (most recent call last)
Cell In[33], line 1
----> 1 model = TaFengMNL(optimizer="lbfgs", epochs=1000)
2 history = model.fit(dataset, verbose=1)
Cell In[32], line 24, in TaFengMNL.init(self, **kwargs)
20 self.price_elasticities = tf.Variable(
21 tf.random_normal_initializer(0.0, 0.02, seed=42)(shape=(1, 3))
22 )
23 # Don't forget to add the weights to be optimized in self.weights !
---> 24 self.trainable_weights = [self.base_utilities, self.price_elasticities]
AttributeError: property 'trainable_weights' of 'TaFengMNL' object has no setter
I see that it's defined in the base class ChoiceModel as a property, but it's not clear to me why the variable assignment it's not working. Also, could you please provide the packages versions (especially of tensorflow since this is the main backend package) used when designing this notebook?
Thank you!
All reactions