Preheat the oven to 350°F (175°C). Grease and line two 8-inch round cake pans with parchment paper.
In a large bowl, whisk together flour, baking powder, baking soda, salt, cinnamon, nutmeg, and ginger.
In another bowl, beat together the granulated sugar, brown sugar, and vegetable oil until well combined. Add the eggs one at a time, beating after each addition. Stir in vanilla extract.
Gradually add the dry ingredients to the wet ingredients, mixing just until combined. Fold in the grated carrots. If using, gently fold in the chopped walnuts.
Divide the batter evenly between the prepared cake pans. Bake for 28–32 minutes, or until a toothpick inserted into the center comes out clean. Let cakes cool in pans for 10 minutes, then transfer to a cooling rack to cool completely.
Meanwhile, prepare the frosting. In a large bowl, beat together the softened cream cheese and butter until smooth. Gradually add powdered sugar, beating until fluffy. Stir in vanilla extract.
Once cakes are cool, place one layer on a serving plate and spread frosting on top. Add the second layer and frost the top and sides of the cake. If desired, garnish with additional chopped walnuts around the edges. For a festive touch, top with carrot candies or pipe carrot shapes using tinted frosting.