Al Shabab fighters stormed the Galcad base early on Friday, exploding car bombs and firing their weapons, Captain Issa Abdullahi said.
The attack was eventually repelled, an officer at the base in the central Somali town of Galcad told Reuters.
He said the dead included the base's deputy commander, who was part of a U.S.-trained unit stationed there.
Somalia's information ministry said in a statement that in addition to al Shabab killing seven soldiers, their soldiers had killed 100 of the group's fighters and destroyed five gun-mounted pick-up vehicles known as technicals.
The base is run by Danab, a unit of commandos who have participated in the offensive against the militants.