Issue in C4W4 UNQ 4 ReformerLM

Please help me. I’m getting the following error. My source code is also shared.

Hi Sumanta_Barman,

Your trax.models.reformer.ReformerLM model should be embedded within a tl.Serial combinator that also includes a tl.LogSoftmax().

1 Like

@reinoudbosch , I am facing the similar problem and do not find the solution.
The error screenshot is as blow

My source code is shared here

def ReformerLM(vocab_size=33000, n_layers=2, mode=‘train’, attention_type=tl.SelfAttention):

# initialize an instance of Trax's ReformerLM class
model = tl.Serial( 
            trax.models.reformer.ReformerLM( 
                # set vocab size
                vocab_size=vocab_size,
                # set number of layers
                n_layers=n_layers,
                # set mode
                mode=mode,
                # set attention type
                attention_type=attention_type
        )
        , tl.LogSoftmax() 
    )        
return model # tl.Serial(model, tl.LogSoftmax(),)

And I also found that there is no “trax.models.reformer.ReformerLM” function on trax official website, the only function related is “trax.models.reformer.reformer.ReformerLM”.

Unfortunately, when I was trying to use “trax.models.reformer.reformer.ReformerLM”, another error occurred as below.
“AttributeError: module ‘trax.models.reformer.reformer’ has no attribute ‘reformer’”

Hi muxin,

You code looks correct to me. This should work if you run it on the coursera platform (it works for me). You could try restarting the kernel and run all cells above UNQ_C5.