I'm trying to adapt the tutorial code to my environment which has the following dimensions:
env.observation_space.shape[0] #Continuous
50
env.action_space.n #Discrete
3
# Define your custom trading environment using the 'TradingEnv' class with your DataFrame
env = TradingEnv(train_df)
# Set the random seed for reproducibility
seed = 0
np.random.seed(seed)
torch.manual_seed(seed)
# Initialize the MuZero model with appropriate parameters for your environment
muzero = Muzero(
model_structure='mlp_model',
observation_space_dimensions=env.observation_space.shape[0], # Use the length of the 1D observation space
action_space_dimensions=env.action_space.n,
state_space_dimensions=61,
hidden_layer_dimensions=126,
number_of_hidden_layer=4,
k_hypothetical_steps=10,
learning_rate=0.01,
optimizer="adam",
lr_scheduler="cosineannealinglr",
loss_type="general",
num_of_epoch=1000,
device="cuda",
type_format=torch.float32,
load=False,
use_amp=False,
bin_method="uniform_bin",
bin_decomposition_number=10,
priority_scale=0.5,
rescale_value_loss=1
)
# Initialize the 'demonstration_buffer', 'replay_buffer', and 'mcts' as per your requirements
# Create the 'gameplay' instance for your custom environment
gameplay = Game(
limit_of_game_play=500,
gym_env=env,
discount=mcts.discount,
observation_dimension=env.observation_space.shape[0], # Use the length of the 1D observation space
action_dimension=env.action_space.n,
rgb_observation=False, # Change to True if you have RGB observations
action_map={i: i for i in range(env.action_space.n)}, # Modify as needed
priority_scale=muzero.priority_scale
)
# Train your model using the 'learning_cycle' function with your adapted environment
epoch_pr, loss, reward, learning_config = learning_cycle(
number_of_iteration=1000,
number_of_self_play_before_training=10,
number_of_training_before_self_play=1,
model_tag_number=450,
temperature_type="static_temperature",
verbose=True,
number_of_worker_selfplay=0,
muzero_model=muzero,
gameplay=gameplay,
monte_carlo_tree_search=mcts,
replay_buffer=replay_buffer
)
TypeError Traceback (most recent call last)
[<ipython-input-22-29674da447ad>](https://localhost:8080/#) in <cell line: 10>()
8
9 # Initialize the MuZero model with appropriate parameters for your environment
---> 10 muzero = Muzero(
11 model_structure='mlp_model',
12 observation_space_dimensions=env.observation_space.shape[0], # Use the length of the 1D observation space
3 frames
[/content/Stochastic-muzero/muzero_model.py](https://localhost:8080/#) in obs_space(self, obs)
492 return int(sum(checker(i) for i in obs))
493 else:
--> 494 return int(checker(obs))
495
496 def one_hot_encode(self, action, counter_part):
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'