Sweating at the gym
If it has been 5 weeks since your procedure it is unlikely that exercise and sweating will affect the grafts or the results. I would recommend getting clearance from your physician, however it generally is not an issue 5 weeks out from surgery.
At 5 weeks there generally isn't any activities you should not be doing with regards to your hair. Most doctors allow strenuous exercise around 2-4 weeks, so you should probably be fine. Your doctor would know best, though.
Sweating and exercise will not affect the transplanted grafts especially after 5 weeks. Losing weight will not affect the grafts either.
Sweating in the gym at 5 weeks
At 5 weeks you can do anything you want except scuba dive. Sweating is fine and a hard workout is all reasonable. We tend to promote professional athletes and tell them they can engage in their professional field without any worry.
Sweating shortly after hair restoration surgery
I always advise my patients to avoid any strenuous activities such as going to the gym at least 10 days after hair restoration surgery because the grafts are not yet settled in completely and popping of the grafts is a possibility.
Should be Good after 5 weeks!
Congrats on the new look! After 5 week the grafts should be settled and good to go. However the weight loss could mean there is something else going on. I would reach out to your doctor and just go in for a quick check-up. Good Luck!
Sweating OK, Weight loss go slowly
Hey there! 5 weeks after the procedure those grafts are all yours! However, since you mention losing weight, make sure you do it in a controlled manner. Crash diets and losing weight quickly can precipitate a "shed" (aka Telogen Effluvium) of the native hair AND the newly growing grafts which would delay your results. Besdies, slow and steady weight loss is more sustainable for the long term anyway. Good luck!