Transformer understanding
The transformer model was introduced in 2017 by Google's paper Attention Is All You Need
.
Below image shows the architecture of the transformer model which is from the Google's paper Attention Is All You Need
.
The transformer model was introduced in 2017 by Google's paper Attention Is All You Need
.
Below image shows the architecture of the transformer model which is from the Google's paper Attention Is All You Need
.
attrdict
trapAttrDict is an MIT-licensed library that provides mapping objects that allow their elements to be accessed both as keys and as attributes.
It's already not support the current python version now, for the lower version python, it's a useful library.
However, there is some magic behavior while using it.
hasattr
difference between 2 and 3hasattr
is a python built in method, which can be used to determine whether an object has an attribute.
For example, we can check the dog object has name
and age
, but doesn't have gender
.
AOP stands for Aspect-Oriented Programming and it helps decouple cross-cutting concerns from the object that they affect. It’s similar to DI in the sense that DI helps decouple an application’s object from each other.
According to the Spring,
ApplicationContext
instanceSometimes, we want to get the ApplicationContext
instance, there are several ways to achieve.
We can inject the ApplicationContext
as a bean into our bean.
From Spring Application Context introduction, we know one of the capability that ApplicationContext
has, but `BeanFactory1 doesn't have is event publication.
ApplicationContext
provides the event handling through the ApplicationEvent
class and the ApplicationListener
interface.
If a bean that implements the ApplicationListener interface is deployed into the context, every time an ApplicationEvent gets published to the ApplicationContext, that bean is notified. Essentially, this is the standard Observer design pattern.
ApplicationContext
?According to the Spring document,
The
org.springframework.beans
andorg.springframework.context
packages are the basis for Spring Framework’s IoC container. TheBeanFactory
interface provides an advanced configuration mechanism capable of managing any type of object.ApplicationContext
is a sub-interface ofBeanFactory
. It adds:
Easier integration with Spring’s AOP features
Message resource handling (for use in internationalization)
Event publication
Application-layer specific contexts such as the WebApplicationContext for use in web applications.
In short, the BeanFactory provides the configuration framework and basic functionality, and the ApplicationContext adds more enterprise-specific functionality. The
ApplicationContext
is a complete superset of theBeanFactory
and is used exclusively in this chapter in descriptions of Spring’s IoC container.
ApplicationContext
is an interface in Spring that provides configuration information to an application. It's the central interface in a Spring application. ApplicationContext is responsible for instantiating, configuring, and assembling beans. It reads configuration metadata to determine what objects to instantiate, configure, and assemble.
ApplicationContext provides basic features, including:
Publishing events to registered listeners
Methods for accessing application components
Internationalization support
Loading file resources
ApplicationContext is read-only while the application is running, but it can be reloaded if the implementation supports it. ApplicationContext is different from BeanFactory. BeanFactory creates a bean object when the getBean()
method is called. ApplicationContext loads all the beans and creates objects at startup.
Spring Bean has four scopes,
singleton
Singleton instance per Spring IoC container. This is the default.
prototype
Scopes a single bean definition to any number of object instances. That means, every time, it requires to inject the bean or the getBean
method is called.
I first learnt Spring in 2008 when I was a student, and I remember that day had a verify famous pattern named SSH, that including,
Spring
Spring is used for manage beans, compared with EJB way, it's very easy for a beginner like me to learn and use.
Struts
Apache Struts was used for MVC, although, it's outdated with current Spring MVC, but in that time, it's much better than using JSPs.
Hibernate
Hibernate is never changed, it's always used as an ORM
After many years experience with Spring, and Spring boot, I am coming up with my mind,