1
$\begingroup$

I just start studying machine learning with Mathematica and, I want to know how make Hinton diagrams. Can someone give an idea, please?

$\endgroup$
  • 8
    $\begingroup$ Can you 1) define Hinton diagrams; 2) provide an example or a link to one; 3) provide sample data to generate such a diagram? $\endgroup$ – MarcoB Mar 29 at 20:11
3
$\begingroup$

Look up Graphics and Rectangle. The following is a starting point that you can improve on.

hinton[matrix_, opt : OptionsPattern[]] :=
 Graphics[
  MapIndexed[
   Style[
     Rectangle[#2 - Abs[#1] {1, 1}/2, #2 + Abs[#1] {1, 1}/2], 
     GrayLevel@UnitStep[#1]
   ] &, 
   matrix, 
   {2}
  ],
  Background -> GrayLevel[1/2],
  opt
 ]

matrix = RandomReal[{-1, 1}, {30, 30}];

hinton[matrix]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.