Preheat the oven to 400 degrees F. Butter a 2-quart baking dish; set aside.
In a medium saucepan over medium heat, add the heavy cream, half and half, rosemary, garlic, butter and salt. Simmer until the cream is slightly reduced, 8 to 10 minutes. Strain and keep warm.
Arrange the sweet potato slices in stacks, placed vertically on their edges, in the prepared baking dish, working along the perimeter of the baking dish at first and then into the center. (The sweet potatoes should be tightly packed.) Scatter with the shallots and then pour in the warm cream mixture. Sprinkle with the Gruyere and top with thyme sprigs and nutmeg.
Loosely cover the baking dish with foil. Bake until the sweet potatoes are easily pierced with a knife, 1 hour 30 minutes. Remove the foil during last 5 minutes of baking.
Recipe courtesy of Tia Mowry